@@ -21,18 +21,33 @@ - (void)setUp {
2121 self.continueAfterFailure = NO ;
2222 self.app = [[XCUIApplication alloc ] init ];
2323 [self .app launch ];
24+ __weak typeof (self) weakSelf = self;
2425 [self addUIInterruptionMonitorWithDescription: @" Permission popups"
2526 handler: ^BOOL (XCUIElement* _Nonnull interruptingElement) {
26- XCUIElement* ok = interruptingElement.buttons [@" OK" ];
27- if (ok.exists ) {
28- [ok tap ];
29- }
30- // iOS 14.
31- XCUIElement* allPhotoPermission =
32- interruptingElement
33- .buttons [@" Allow Access to All Photos" ];
34- if (allPhotoPermission.exists ) {
27+ if (@available (iOS 14 , *)) {
28+ XCUIElement* allPhotoPermission =
29+ interruptingElement
30+ .buttons [@" Allow Access to All Photos" ];
31+ if (![allPhotoPermission waitForExistenceWithTimeout:
32+ kElementWaitingTime ]) {
33+ os_log_error (OS_LOG_DEFAULT, " %@" ,
34+ self.app .debugDescription );
35+ XCTFail (@" Failed due to not able to find "
36+ @" allPhotoPermission button with %@ seconds" ,
37+ @(kElementWaitingTime ));
38+ }
3539 [allPhotoPermission tap ];
40+ } else {
41+ XCUIElement* ok = interruptingElement.buttons [@" OK" ];
42+ if (![ok waitForExistenceWithTimeout:
43+ kElementWaitingTime ]) {
44+ os_log_error (OS_LOG_DEFAULT, " %@" ,
45+ self.app .debugDescription );
46+ XCTFail (@" Failed due to not able to find ok button "
47+ @" with %@ seconds" ,
48+ @(kElementWaitingTime ));
49+ }
50+ [ok tap ];
3651 }
3752 return YES ;
3853 }];
@@ -92,10 +107,21 @@ - (void)launchPickerAndCancel {
92107 [cancelButton tap ];
93108
94109 // Find the "not picked image text".
95- XCUIElement* imageNotPickedText = [self .app.otherElements
110+ XCUIElement* imageNotPickedText = [self .app.staticTexts
96111 elementMatchingPredicate: [NSPredicate
97112 predicateWithFormat: @" label == %@ " ,
98113 @" You have not yet picked an image." ]];
114+ if (![imageNotPickedText waitForExistenceWithTimeout: kElementWaitingTime ]) {
115+ // Before https://github.com/flutter/engine/pull/22811 the label's a11y type was otherElements.
116+ // TODO(cyanglaz): Remove this after
117+ // https://github.com/flutter/flutter/commit/057e8230743ec96f33b73948ccd6b80081e3615e rolled to
118+ // stable.
119+ // https://github.com/flutter/flutter/issues/71927
120+ imageNotPickedText = [self .app.otherElements
121+ elementMatchingPredicate: [NSPredicate
122+ predicateWithFormat: @" label == %@ " ,
123+ @" You have not yet picked an image." ]];
124+ }
99125 if (![imageNotPickedText waitForExistenceWithTimeout: kElementWaitingTime ]) {
100126 os_log_error (OS_LOG_DEFAULT, " %@" , self.app .debugDescription );
101127 XCTFail (@" Failed due to not able to find imageNotPickedText with %@ seconds" ,
0 commit comments