[英]iOS Automation - Selecting a photo from Camera Roll
我正在用XCode編寫UI自動化測試,並且需要從我的應用程序中彈出的“相機膠卷”屏幕中選擇一張照片。 我在網上看了一下,但似乎找不到有關如何執行此操作的任何信息。 有人知道這是否可能嗎?
來自另一個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()
//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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.