ios - Xcode 用户界面测试 : staticTexts start with

标签 ios xcode swift xcode-ui-testing

我想检查我的用户界面上是否存在以前缀开头的元素。如何在 Xcode 7 UI 测试中实现它?

app.tables["AAA"].staticTexts["Fax: 0049XXXXXXXX"].exists

我在一个 tableview 单元格中有三个元素,只有一个(第三个或最后一个)以前缀 Fax: 0049 开头。我如何检查这个元素的存在?

我试过

app.tables["AAA"].cells.staticTexts.elementBoundByIndex(2).exists

但是什么都没有,一些想法? 干杯

最佳答案

您可以使用 BEGINSWITH 谓词来检查元素是否以前缀开头。

let app = XCUIApplication()
let faxPredicate = NSPredicate(format: "label BEGINSWITH 'Fax: '")
let faxLabel = app.staticTexts.element(matching: faxPredicate)
XCTAssert(faxLabel.exists)

这是一个使用不同的 BEGINSWITH 谓词选择元素的工作示例,a picker with multiple wheels .

关于ios - Xcode 用户界面测试 : staticTexts start with,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35509177/

相关文章:

iphone - iPhone 5 上的图像遍布整个屏幕

Objective-C:检查 View 是否触及另一个 View

ios - 断言失败的 UIWebView 崩溃 : (addr ! = MAP_FAILED),函数 _open_and_mmap_for_reading

ios - UITabBarController自动生成的自定义tableview

ios - SwiftUI navigationBarHidden 不起作用并抛出错误

objective-c - 如何在 Swift/XCode 中的 Controller 之间共享(MVC)模型?

ios - 在 View Controller 上强制方向

ios - 如何更改 Xcode4.3 Organizer 的存储库名称

ios - ios 中 USDZ 文件位于我的头顶

ios - 来自肖像 UIImage 的 CGImage