Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 7 UI Tests fail with "Timed out waiting for key event to complete"

My team and I have been setting up a Jenkins server to automate running unit and ui tests on a Mac Mini that we use as a build server. This Mac Mini has no peripherals attached to it, and the only way we can access it is by logging in remotely.

When I am logged into the machine remotely, using my Mac's built in Screen Sharing App, the tests run just fine using the iOS simulator. However, if I close out of the remote connection while the tests are running, ui tests that involve typing text will fail with the following error when attempting to type (all other tests / ui tests pass with flying colours):

Assertion Failure: Timed out waiting for key event to complete

This obviously causes some problems when Jenkins is automatically running the tests for us, since we don't always want to be remotely logged into the machine.

I feel like this has something to do with the software keyboard of the simulator but am failing to see why it would be an issue. Does the mac need to have some sort of display output connected in order for the software keyboard to exist or some such thing? Would connecting a monitor to the machine (even if it's not really being used) cause the tests to pass? Why would this be the case?

like image 324
David Bagwell Avatar asked Nov 30 '15 22:11

David Bagwell


2 Answers

Xcode 10 still has the same issue after you presented a CNContactViewController instance.

Avoid write those cases which need call CNContactViewController` instance.

Or there is a workaround:

app.keys["1"].tap()
app.keys["2"].tap()
app.keys["3"].tap()
like image 181
beimenjun Avatar answered Oct 09 '22 03:10

beimenjun


This problem could be sorted out by turning off the connected hardware keyboard in the simulator settings for few.

You may also want to try that UI Testing Failure - Neither element nor any descendant has keyboard focus on TextView

like image 5
Yogesh Khatri Avatar answered Oct 09 '22 03:10

Yogesh Khatri