Reputation: 1571
I'm new to XCUITest and have come across a problem where it's not recognizing an alert.
I used the recorder to get the commands, but when I try to play it back, it fails with an error saying:
No matches found for Find: Descendants matching type Alert from input...
let app = XCUIApplication()
app.navigationBars["Spree.HomeWebView"].children(matching: .button).element(boundBy: 1).tap()
app.alerts["Select a Saved Password to Use With “Spree-DEBUG”"].buttons["Not Now"].tap()
I thought it might be a problem with the double quotes in the string, but when I tried the following:
app.alerts["Select a Saved Password to Use With \“Spree-DEBUG\”"].buttons["Not Now"].tap()
It said Invalid escape sequence in the literal.
Upvotes: 0
Views: 1554
Reputation: 1
Finally, I found a real solution, basically what happens iOS 11-12 works fine with a handler, but iOS13 doesn't if you uninstall app during automation. So as guys provided you need to use springboard activity to handle alerts which are not part of the app, and conclusion:
Upvotes: 0
Reputation: 2210
Since you want to query a button that is inside an alert, you can omit whole alerts subscript part of your query. Just like:
app.alerts.buttons["Not Now"].tap()
This is because you probably don't have more than one alert shown at the same time, so querying all alerts
should give the one you need since you only have one, right :)
Upvotes: 0