I have an XCTest case which is trying to enter text into a text field.
let app = XCUIApplication()
let query = app.tables
query.staticTexts[“New..."].tap()
let serverAddress = query.cells.containing(.cell, identifier:"serverTableViewCell").textFields.element
if serverAddress.exists {
serverAddress.tap()
serverAddress.typeText(server)
}
This has to run on a physical device, because the application is a Network Extension VPN.
It generally works fine, but every now and then it starts failing. When it fails everything looks like it's succeeding.
- I can find the field
- I can tap on the field, and I see the text cursor
- I can call typeText()
No errors, messages, informative output... But nothing appears in the text field.
This appears to happen after there's been some sort of system dialog on the device (not entirely sure it's related, but the correlation is strong) but even once that dialog is gone the test continues to fail.
Things are complicated because the device is in the office--and we aren't allowed to go into the office at the moment. I can't re-start the device, because I'm pretty sure that will require physical presence at the device to unlock it again.
I *can* alter settings on the device using teh XCTest interfaces to control System Settings. I tried disabling all notifications, but things are still failing.
I saw a similar question with the same symptoms, but it was on a simulator, and the solution was to reset the simulator. Not an option in this case: https://forums.developer.apple.com/thread/125010
Is it possible that once the system dialog/alert/notification is apparently gone that it's still hogging keyboard input? If that is the case, anyone know how I could clear it? Without being physically present at the device?
Any other suggestions would be great.