swift - XCUI测试: Is it possible to tap on element not using static texts present but identifier?

标签 swift xcode8 xcuitest

我目前正在尝试使用 XCUITest 框架对 parking 移动应用程序进行自动化测试。问题是,每次单击按钮时,我不想单击与该元素关联的静态文本(因为文本会发生变化),而是单击 ID。有办法做到这一点吗?

最佳答案

您可以使用 matching(identifier:) 函数通过标识符来匹配元素

https://developer.apple.com/documentation/xctest/xcuielementquery/1500679-matching

链接 .firstmatch.element 以匹配单个元素。

关于swift - XCUI测试: Is it possible to tap on element not using static texts present but identifier?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57322672/

相关文章:

ios - 使用 React Native 进行 UI 测试。如何修复时间戳事件匹配错误 : Failed to find matching element

ios - 向 UILabel 添加填充

ios - 代码 8 : Enable wireless capability for Wildcard App ID

ios - XCUITest、UIDatePicker、adjustToPickerWheelValue

url-scheme - 添加 url 方案后,iOS 9.3.5 无法通过我的应用程序访问互联网

ios - 应用过滤器时出现 NSInvalidArgumentException

php - JSON 解析 --> Swift | JSON 写入中的顶级类型无效

iOS - AutoLayout 约束设置激活在第二次崩溃

swift - 如何在 Swift 中覆盖协议(protocol)扩展的计算属性