所以在XCUITest中,我使用下面的代码来获取一个按钮:
XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *button = app.buttons[@"button_identifier"];使用app.tables获取表视图,使用app.images获取图像,依此类推。
但是怎样才能获得视图(UIView)呢?
发布于 2016-03-15 05:48:32
Objective-C
XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *customView = app.otherElements[@"view_identifier"];斯威夫特
let app = XCUIApplication()
let customView = app.otherElements["view_identifier"]发布于 2018-07-17 16:56:05
对于Swift 3/4,它将如下所示:
let app = XCUIApplication()
let custom_view = app.otherElements["view_identifier"]我还喜欢做的是有一个类变量,因为我经常在不同的测试中重用这些视图:
lazy var custom_view: XCUIElement = { return XCUIApplication().otherElements["view_identifier"] }()https://stackoverflow.com/questions/35998502
复制相似问题