5

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?

3
  • Did you find a way to solve that without modifying the HTML?
    – Ruxel
    Dec 17, 2019 at 13:22
  • No. I've raised an Apple Feedback Assistant issue (FB7492689) but no comment yet. I suspect this issue would also cause Voice Over problems reading the HTML out on a device but I haven't tested that. Apple might be more responsive to user-level accessibility bug reports than developer code-level reports.
    – Ben
    Dec 20, 2019 at 11:36
  • FYI - forums.developer.apple.com/thread/127246
    – badInode
    Jan 6, 2020 at 23:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy