I want to have a test pause and wait for an element to appear on screen before proceeding.
I don\'t see a good way to create an expectation for this and wait using
For Xcode 8.3 and later you can wait for expectation with a new class - XCTWaiter
, an example test looks like this:
func testExample() {
let element = // ...
let predicate = NSPredicate(format: "exists == true")
let expectation = XCTNSPredicateExpectation(predicate: predicate, object: element)
let result = XCTWaiter().wait(for: [expectation], timeout: 1)
XCTAssertEqual(.completed, result)
}
Read the documentation for more information.