Delay/Wait in a test case of Xcode UI testing
Asynchronous UI Testing was introduced in Xcode 7 Beta 4. To wait for a label with the text "Hello, world!" to appear you can do the following:
let app = XCUIApplication()
app.launch()
let label = app.staticTexts["Hello, world!"]
let exists = NSPredicate(format: "exists == 1")
expectationForPredicate(exists, evaluatedWithObject: label, handler: nil)
waitForExpectationsWithTimeout(5, handler: nil)
More details about UI Testing can be found on my blog.
Additionally, you can just sleep:
sleep(10)
Since the UITests run in another process, this works. I don’t know how advisable it is, but it works.