如何解决我们可以为XCUIElement创建NSPredicate来匹配accessibilityTraits吗?
我不熟悉使用Swift进行iOS UI自动化。 我们的框架正在使用XCUIApplication为我们的应用程序自动化UI。 我们使用NSPredicate查找元素,如下所示:
let query = XCUIApplication()
.descendants(matching: XCUIElement.ElementType.any)
.matching(matcher.getMatcher() as! NSPredicate)
我们创建各种谓词,如下所示:
// Predicate to find an element using accessibility label
func getLabelMatcher() -> Any {
NSPredicate { (e,_) in (e as! XCUIElementAttributes).label == self.label }
}
// Predicate to find an element using accessibility id
func getIdMatcher() -> Any {
NSPredicate { (e,_) in (e as! XCUIElementAttributes).identifier == self.id }
}
// Predicate to check if element exists
func getDisplayedMatcher() -> Any {
NSPredicate { (e,_) in (e as! XCUIElement).exists }
}
我的疑问是:
- 遍历XCUIElement Docs和XCUIElementAttributes Docs,看来accessibilityTraits属性对他们不可用。有什么办法可以使用
UIAccessibilityTraits
找到XCUI元素?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。