我正在XCode中编写UI自动化测试,需要从我的应用程序中弹出的Camera Roll屏幕中选择一张照片。我在线查看但似乎无法找到有关如何执行此操作的任何信息。有谁知道这是否可行?
答案 0 :(得分:1)
其他StackOverflow问题的代码不起作用,所以我自己弄清楚了。点击照片本身不起作用,但点击照片的坐标位置似乎工作正常。
let image = Page.app.collectionViews.children(matching: .cell).element(boundBy: 0)
let coord:XCUICoordinate = image.coordinate(withNormalizedOffset: CGVector.init(dx: 0.0, dy: 0.0))
coord.tap()
答案 1 :(得分:0)
//Title For Photos
XCTAssertTrue(XCUIApplication().navigationBars.otherElements["Photos"].waitForExistence(timeout: 5))
//Check if Moments is visible on the view
XCTAssertTrue(XCUIApplication().otherElements.tables.cells["Moments"].waitForExistence(timeout: 5))
//Click on Moments to see the image collection list
XCUIApplication().otherElements.tables.cells["Moments"].tap()
//Checking for "Photo, Portrait, August 08, 2012, 11:29 PM" exist
XCTAssertTrue(XCUIApplication().otherElements.collectionViews.cells["Photo, Landscape, August 08, 2012, 8:52 PM"].waitForExistence(timeout: 5))
//Clicking on "Photo, Portrait, August 08, 2012, 11:29 PM"
XCUIApplication().otherElements.collectionViews.cells["Photo, Landscape, August 08, 2012, 8:52 PM"].tap()