Error click on location's permission pop alert in iOS 17

Hi there,

I am having a problem when a pop up of location permission is showed, I am able to switch to the alert and get the alert text, but for any reason i am not able to click on ‘Allow Once’ o wathever other option, the error says that was not able to find the element:

Switch.toAlert().getText(); -> I get the alert text succesfully 
//XCUIElementTypeButton[@name=\"Allow While Using App\"]";  -> does not find the element 

I am using iOS 17, appium 2.12

Looks like you want to accept:

Switch.toAlert().accept();

See more here:

The latest xcuitest driver has a “respectSystemAlerts” setting. You need to set it to true and after that you can interact with locator like this:
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeButton[`label == "Allow While Using App"`]")

1 Like

Hi @wreed thank you for your response, the page linked helped me so much with the fix, finally I used this implementation and it works very well:

args.put("action", "accept");
args.put("buttonLabel", buttonLabel);
driver.executeScript("mobile: alert", args);

Thank you so much!!!

1 Like

Hi @SeresProduction i tried with that implementation but the element was not found anytime, i tried with different ways to localize the element but at the end it was not possible.