Last active
April 24, 2018 10:44
-
-
Save pilot34/1ad965ea6e05dd40d282453051c13a34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func wait(forWebViewElement element: XCUIElementTypeQueryProvider, timeout: TimeInterval = 20) { | |
// xcode has bug, so we cannot directly access webViews XCUIElements | |
// as a workaround we can check debugDesciption and parse it, that works | |
let predicate = NSPredicate { obj, _ in | |
guard let el = obj as? XCUIElement else { | |
return false | |
} | |
// If element has firstMatch, than there will be description of that at the end | |
// If no match - it will be ended with "FirstMatch\n" | |
return !el.firstMatch.debugDescription.hasSuffix("First Match\n") | |
} | |
// we need to take .firstMatch, because we parse description for that | |
let e = XCTNSPredicateExpectation(predicate: predicate, object: element.firstMatch) | |
let result = XCTWaiter().wait(for: [ e ], timeout: timeout) | |
XCTAssert(result == .completed) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment