为什么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)有时是XCUIElementAttributesXCUIElementSnapshotXCUIElement

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)