I have been trying the new UI testing functionality in Xcode7, after watching the WWDC 2015 session video "UI Testing in Xcode".
When my app launches, a view animates into the center of the screen with two text fields for the user to enter their user name and password.
I have recorded a test where I enter the user name, hit 'next' on the keyboard (causing the "password" text field to become first responder), then entered the password, and hit "Go" (to trigger the authentication process).
When I try to "Run" the recorded test, it fails because the text fields aren't available right away:
Test Suite 'Selected tests' started at 2015-08-14 13:14:19.454
Test Suite 'MyAppUITests' started at 2015-08-14 13:14:19.454
Test Case '-[MyAppUITests.MyAppUITests testExample]' started.
t = 0.00s Start Test
t = 0.00s Set Up
t = 0.00s Launch com.myCompany.MyApp
2015-08-14 13:14:19.953 XCTRunner[4667:451922] Continuing to run tests in the background with task ID 1
t = 2.64s Waiting for accessibility to load
t = 6.20s Wait for app to idle
t = 6.49s Tap "User ID" TextField
t = 6.49s Wait for app to idle
t = 6.57s Find the "User ID" TextField
t = 6.57s Snapshot accessibility hierarchy for com.myCompany.MyApp
t = 6.60s Find: Descendants matching type TextField
t = 6.60s Find: Elements matching predicate '"User ID" IN identifiers'
t = 6.60s Wait for app to idle
t = 6.67s Synthesize event
t = 6.74s Scroll element to visible
t = 6.78s Assertion Failure: UI Testing Failure - Failed to scroll to visible (by AX action) TextField 0x7fc90251a130: traits: 146029150208, {{107.0, 807.0}, {200.0, 30.0}}, placeholderValue: 'User ID', value: fffffaaaa, error: Error -25204 performing AXAction 2003
<unknown>:0: error: -[MyAppUITests.MyAppUITests testExample] : UI Testing Failure - Failed to scroll to visible (by AX action) TextField 0x7fc90251a130: traits: 146029150208, {{107.0, 807.0}, {200.0, 30.0}}, placeholderValue: 'User ID', value: fffffaaaa, error: Error -25204 performing AXAction 2003
t = 6.78s Tear Down
Test Case '-[MyAppUITests.MyAppUITests testExample]' failed (6.783 seconds).
Test Suite 'MyAppUITests' failed at 2015-08-14 13:14:26.238.
Executed 1 test, with 1 failure (0 unexpected) in 6.783 (6.784) secondsThe view containing the text fields is hidden below, off-screen, and it scrolls up to the center of the screen by means of an animation, after the view controller's view appears.
How can I make the recorded actions to wait until the target control becomes available?