Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么NSPredicate的XUIApplication元素类型不同?_Ios_Swift_Ui Automation_Xctest - Fatal编程技术网

Ios 为什么NSPredicate的XUIApplication元素类型不同?

Ios 为什么NSPredicate的XUIApplication元素类型不同?,ios,swift,ui-automation,xctest,Ios,Swift,Ui Automation,Xctest,我不熟悉iOS XCUI自动化。我们正在使用NSPredicate查找元素 let query = self.application .descendants(matching: XCUIElement.ElementType.any) .matching(matcher.getMatcher() as! NSPredicate) 当我们试图创建谓词时,元素类型是不同的 // Predicate to find an element using

我不熟悉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)有时是
xguielementattributes
xguielementsnapshot
xguielement