Our app is hybrid and contains webview. I'm trying to automate our app using Xcode UI Testing. I was able to locate web buttons using:
let app = XCUIApplication()
app.launch()
let button = app.staticTexts["Button's text"]
But in one of our tests we test localization - meaning the text changes and the static text query is no longer valid. Couldn't find any documentation how to locate an element by his id (or even class name). Any ideas?
I have had a similar problem trying to fill in text fields in a SFSafariViewController.
I found that using the aria-label attribute allowed me to locate elements in the page e.g.
<input role="textbox" aria-label="email" type="email" value="" name="user[email]" id="user_email">
And then in your code to select that element
webViewsQuery.textFields["email"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With