XCUITest 检测 UIView

MNI*_*RAM 5 xcode automated-tests uiview xctest

所以在 XCUITest 中,我使用这个代码来获取一个按钮:

XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *button = app.buttons[@"button_identifier"];
Run Code Online (Sandbox Code Playgroud)

获取 tableview usingapp.tables和 image usingapp.images等等。

但是我怎样才能得到一个视图(UIView)?

MNI*_*RAM 5

目标-C

XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *customView = app.otherElements[@"view_identifier"];
Run Code Online (Sandbox Code Playgroud)

迅速

let app = XCUIApplication()
let customView = app.otherElements["view_identifier"]
Run Code Online (Sandbox Code Playgroud)