如何解决为什么XCUIApplication元素的类型与NSPredicate不同?
我是iOS XCUI自动化的新手。我们正在使用NSPredicate
查找元素。
let query = self.application
.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 }
}
为什么NSPredicate闭包对象(在这种情况下为e)有时是XCUIElementAttributes
,XCUIElementSnapshot
和XCUIElement
?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。