Something has changed about the XCTest automation/accessibility behaviour in the iOS 13.3 simulator that has shipped with Xcode 11.3. My UI test code suddenly can't find a textField inside a WKWebView.
I have had a UI test that has worked fine for a long time, including in iOS 13.2 sims. The test looks for a textField with a certain value. Here is some test HTML, loaded into a WKWebView using loadFileURL
:
<body>
<div>
<input type="text" placeholder="User name">
</div>
<body>
And here is the test code. The test passes in iOS 13.2 and you can see the text being entered. In iOS 13.3 it never finds the element and the test fails:
func testExample() {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()
// Enter text in the username field
let userNameField = app.webViews.textFields["User name"]
if userNameField.waitForExistence(timeout: 10) {
userNameField.tap()
userNameField.typeText("Harry Potter")
}
XCTAssert(userNameField.exists)
}
If I add a single character inside the <div>
before the <input>
in the HTML, then the test works.
If I run the same code on the iOS 13.2 sim, even using Xcode 11.3, it works fine. It only fails on the iOS 13.3 sim.
Can anyone shed light on what is going on?