Skip to content

Commit 9ce1570

Browse files
authored
[image_picker_ios] Update image picker UI test query for iOS 18 (flutter#7325)
The image picker UI changed from iOS 17 -> iOS 18 (beta), and there's an additional scrollview that wasn't present before. Instead of selecting the first image in the first scroll view, instead select the image with the accessibility label that starts with "Photo": ``` ��Find: First Match Output: { Image, 0x10134f070, {{-0.0, 339.7}, {142.2, 142.3}}, label: 'Photo, March 30, 2018, 12:14�PM' } ``` This works on previous versions of iOS as well. Fixes flutter#150220, found in Xcode 16 beta.
1 parent ec92d7d commit 9ce1570

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

packages/image_picker/image_picker_ios/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## NEXT
2+
3+
* Updates UI test photo element query for iOS 18.
4+
15
## 0.8.12
26

37
* Re-adds Swift Package Manager compatibility.

packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ - (void)launchPickerAndPickWithMaxWidth:(NSNumber *)maxWidth
201201
// Find an image and tap on it. (IOS 14 UI, images are showing directly)
202202
XCUIElement *aImage;
203203
if (@available(iOS 14, *)) {
204-
aImage = [self.app.scrollViews.firstMatch.images elementBoundByIndex:1];
204+
NSPredicate *imagePredicate = [NSPredicate predicateWithFormat:@"label BEGINSWITH 'Photo, '"];
205+
aImage = [self.app.images matchingPredicate:imagePredicate].firstMatch;
205206
} else {
206207
XCUIElement *allPhotosCell = self.app.cells[@"All Photos"].firstMatch;
207208
if (![allPhotosCell waitForExistenceWithTimeout:kElementWaitingTime]) {

packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ - (void)testSelectingFromGallery API_AVAILABLE(ios(14)) {
107107
[self handlePermissionInterruption];
108108

109109
// Find an image and tap on it.
110-
XCUIElement *aImage = [self.app.scrollViews.firstMatch.images elementBoundByIndex:1];
110+
NSPredicate *imagePredicate = [NSPredicate predicateWithFormat:@"label BEGINSWITH 'Photo, '"];
111+
XCUIElementQuery *imageQuery = [self.app.images matchingPredicate:imagePredicate];
112+
XCUIElement *aImage = imageQuery.firstMatch;
111113
os_log_error(OS_LOG_DEFAULT, "description before picking image %@", self.app.debugDescription);
112114
if (![aImage waitForExistenceWithTimeout:kLimitedElementWaitingTime]) {
113115
os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription);
@@ -126,7 +128,7 @@ - (void)testSelectingFromGallery API_AVAILABLE(ios(14)) {
126128
[doneButton tap];
127129

128130
// Find an image and tap on it to have access to selected photos.
129-
aImage = [self.app.scrollViews.firstMatch.images elementBoundByIndex:1];
131+
aImage = imageQuery.firstMatch;
130132

131133
os_log_error(OS_LOG_DEFAULT, "description before picking image %@", self.app.debugDescription);
132134
if (![aImage waitForExistenceWithTimeout:kLimitedElementWaitingTime]) {

0 commit comments

Comments
 (0)