繁体   English   中英

iOS自动化-从相机胶卷中选择照片

[英]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()

Swift 4+ Automation,用于选择图像

//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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM