I have “autoAcceptAlerts” set to “true” but
native iOS alerts aren’t automatically accepted on a real device.

This is about providing the same in the capabilities .please check you desired capabilities fort he same

Which capability is needed since the new appium version to accept alerts automatically?

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“autoAcceptAlerts”, true);

Hope that will help.

Thank you for your answer
I already has got this capability in my code, but is not working

I think it is a known issue currently.

I am facing the same issue with iOS real device with Appium v1.6.3 and Java Client 5.0.0-BETA3. Please suggest me the solution.

@Nikhil_jain this don’t work with XCUITest. You have to handle it manually

Can you please help me to handle the accept the alerts , when I search for that element using xpath = "//*[contains(@label,‘Allow’)] there after I have used click method.

It is clicking on the button(no exception thrown) but the pop up is not closing. Could you please share code to handle that ?

I am using APPIUM 1.6.4 and IOS 10.2

This is what I am using to accept the pop up

if (driver.findElementByXPath("//XCUIElementTypeAlert[1]").isDisplayed()) {
LOG.info(“Alert is present”);
WebDriverWait wait = new WebDriverWait(driver, 200);
} else {
LOG.info(“Alert is not present”);

Doesn’t this statement throws the NoSuchElementException when there is no Alert is present ?

I have handle the same as below my query is without having the exception thrown if alert is present then it should click otherwise without throwing the exception I should be able to handle the alert

try { driver.switchTo().alert().accept(); } catch (NoAlertPresentException e) { logger.warn("Alert is not present" + e.getMessage()); }

Even it’s an old topic I decided to contribute with what happened to me today when testing a WebApp on Safari in Simulator (iPhone 12 Pro Max - iOS 14.4). In my case was an alert about a popup that would be opened. Thank God I found what was missing. Beyond the capabilities safariAllowPopups: true, autoAcceptAlerts: true it’s necessary include this one as well: nativeWebTap: true