4

I am writing an XCTest test for a webview that contains HTML. I want to be able to find elements in the HTML DOM by an attribute different than value. Looking for something like an accessibility label.

I have tried the approach below

<input label="Rob" value="Rob" alt="Rob" caption="Rob" aria-labelledby="Rob" for="Rob" type="Rob" accessibilityTitle="Rob" accessibilityLabel="Rob" id="Rob" name="Rob" arial-label="Rob" _ placeholder="Search..." type="text">

I am looking to search by the id "Rob" but the only way how the element can be accessed is

let searchTextField = XCUIApplication().webViews.textFields["Search..."]

Any idea how to find element from webview in XCTest by any label/accessibility identifier is much appreciated.

Robert Varga
  • 321
  • 2
  • 4
  • 10
  • Robert Varga, did you find an answer for this? I need to set the accessibility identifier within the html page. – Edgardo Agno Feb 07 '23 at 10:08
  • There's an answer here, but not sure if it's still applicable https://stackoverflow.com/questions/33080796/how-to-add-accessibility-identifier-to-ios-cordova-webview-in-html – Edgardo Agno Feb 07 '23 at 10:13

0 Answers0