Created
April 12, 2022 18:08
-
-
Save bitops/9182b5ee96c682aba57d9fa16ca6b987 to your computer and use it in GitHub Desktop.
How to tap the pre-loaded photos in the camera roll in iOS UI test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
LIKE: The left hand expression equals the right-hand expression: ? and * are allowed as wildcard characters, where ? matches 1 character and * matches 0 or more characters. | |
Resource: https://nshipster.com/nspredicate/ | |
*/ | |
let yellowLeafGreenBackground = NSPredicate(format: "label LIKE 'Photo, October 09, 2009, *:09*'") | |
let waterfallCloseUpOverRocks = NSPredicate(format: "label LIKE 'Photo, August 08, 2012, *:29*'") | |
let treeWithWaterfallBackground = NSPredicate(format: "label LIKE 'Photo, August 08, 2012, *:52*'") | |
let yellowFlowerSucculentBeach = NSPredicate(format: "label LIKE 'Photo, March 12, 2011, *:17*'") | |
let amazingWaterfall = NSPredicate(format: "label LIKE 'Photo, August 08, 2012, *:55*'") | |
// take note with this one, it is an HDR image | |
let beautyFlowers = NSPredicate(format: "label LIKE 'Photo, March 30, 2018, *:14*'") | |
func testTappingOnSpecificImage() { | |
// ... test setup and navigation to get to presented Camera Roll (PHPicker or UIImagePickerController) | |
// trigger presentation of camera roll | |
app.buttons["Choose from Photos"].tap() | |
XCTAssertTrue(app.buttons["Cancel"].waitForExistence(timeout: 3)) | |
let activeQuery = treeWithWaterfallBackground | |
app.scrollViews.otherElements.images.matching(activeQuery).element.tap() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment