File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,16 +12,23 @@ extension XCUIElement {
1212 // Avoid unnecessary waiting if the element is already hittable
1313 guard isHittable == false else { return true }
1414
15- let result = XCTWaiter . wait (
16- for: [
17- XCTNSPredicateExpectation (
18- predicate: NSPredicate ( format: " isHittable == true " ) ,
19- object: self
20- )
21- ] ,
15+ return waitFor ( predicateString: " isHittable == true " , timeout: timeout) == . completed
16+ }
17+
18+ /// Uses the given `String` to create an `NSPredicate` and waits for it to be true on `self` for
19+ /// the given `timeout` (defaults to 3 seconds)
20+ @discardableResult
21+ public func waitFor( predicateString: String , timeout: TimeInterval = 3.0 ) -> XCTWaiter . Result {
22+ waitFor ( predicate: NSPredicate ( format: predicateString) , timeout: timeout)
23+ }
24+
25+ /// Waits for the given `NSPredicate` to be true on `self` for the given `timeout` (default to
26+ /// 3 seconds)
27+ @discardableResult
28+ public func waitFor( predicate: NSPredicate , timeout: TimeInterval = 3.0 ) -> XCTWaiter . Result {
29+ XCTWaiter . wait (
30+ for: [ XCTNSPredicateExpectation ( predicate: predicate, object: self ) ] ,
2231 timeout: timeout
2332 )
24-
25- return result == . completed
2633 }
2734}
You can’t perform that action at this time.
0 commit comments