我尝试在Xcode7测试版上进行UI测试。
在XCUIElement被解除后,它的.exists属性仍然是YES。
例如:
XCUIElement *button = app.sheets[@"Sample sheet"].buttons[@"Sample button"];
[button tap]; // Tapping will dismiss UIActionSheet and its button will no longer exist.
XCTAssertFalse(button.exists); // -> Error here.有什么方法可以检测到XCUIElement在被清除后不存在吗?
发布于 2016-01-30 05:02:42
XCUIElement有一个返回BOOL的exists方法。
在你的代码中:
if (button.exists) {
[button tap];
}发布于 2017-03-16 22:02:50
最好的方法是在触发tap事件之前检查XCUIElement是否存在和是否可访问
在你的代码中:
if (button.exists && button.isHitable) {
[button tap];
}发布于 2015-10-07 19:01:12
您可以检查app.sheets.count
https://stackoverflow.com/questions/31824457
复制相似问题