Issue with XCUITest in landscape orientation.

Originator:yuriy.pertsev
Number:rdar://6468254620 Date Originated:8/14/2017
Status:Open Resolved:No
Product:XCUITest Product Version:10.0
Classification:Crash Reproducible:80%
 
Summary:
The issue sometimes appear when test changes the orientation of the simulator on CI Jenkins and try type text to UITextField. With error:
UI Testing Failure - Neither element nor any descendant has keyboard focus.

If I run test locally the test is successful but on Jenkins this issue appear sometimes. 
I found that this issue can be resolve if add additional tap on UITextField. I done this. 
After that I got error:
05:35:46     t =    15.61s     Tap "EmailFieldID" TextField
05:35:46     t =    15.61s         Wait for app to idle
05:35:46     t =    16.07s         Find the "EmailFieldID" TextField
05:35:46     t =    16.07s             Snapshot accessibility hierarchy for com.sample
05:35:46     t =    16.13s             Find: Descendants matching type Any
05:35:46     t =    16.14s             Find: Elements matching predicate '"EmailFieldID" IN identifiers'
05:35:46     t =    16.88s             Wait for app to idle
05:35:46     t =    32.88s                 Unable to monitor animations
05:35:46     t =    47.89s                 Unable to monitor event loop
05:35:46     t =    47.89s         Synthesize event
05:35:46     t =    63.10s             Assertion Failure: SampleUITests.m:184: UI Testing Failure - Failed to get attributes within 15.0s: (
05:35:46     2062,
05:35:46     2021,
05:35:46     2123
05:35:46 )
or
03:52:34     t =    28.73s     Tap "EmailFieldID" TextField
03:52:34     t =    28.74s         Wait for app to idle
03:52:34     t =    29.03s         Find the "EmailFieldID" TextField
03:52:34     t =    29.03s             Snapshot accessibility hierarchy for com.sample
03:52:34     t =    29.08s             Find: Descendants matching type Any
03:52:34     t =    29.09s             Find: Elements matching predicate '"EmailFieldID" IN identifiers'
03:52:34     t =    29.09s             Wait for app to idle
03:52:34     t =    30.15s         Synthesize event
03:52:34     t =    32.86s         Wait for app to idle
03:52:34     t =    47.93s             Unable to monitor animations
03:52:34     t =    62.94s             Unable to monitor event loop
03:52:34     t =    62.94s     Snapshot accessibility hierarchy for com.sample
03:52:34     t =    78.10s         Assertion Failure: SampleUITests.m:185: UI Testing Failure - Failed to get snapshot within 15.0s
03:52:34     t =    78.10s     Tear Down
03:52:34     t =    78.10s         Set device orientation to Portrait

I found that this is common issue but how to fix this decision is not present.

The example of code:

    XCUIElement *emailField = [[application descendantsMatchingType:XCUIElementTypeAny] objectForKeyedSubscript:EmailFieldID];
    
    [emailField tap];
    
    [emailField typeText:email];
    
Steps to Reproduce:
I created test
Launch this test on CI Jenkins
Sometimes this issue reproduce.

Expected Results:
All test run successful.

Observed Results:
Sometimes the test failed with reproducible - 80%

Configuration:
Xcode 8 
iOS 10.0
Simulator: iPhone 6 10.0

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!