Recently when I load iOS app I'm getting overlaping alerts, and I'm unable to communicate to them

Recently, something changed on iOS devices, but it wasn’t due to a new iOS version or an Xcode build, appium or selenium updates. It feels like Apple may have made an update without any announcements. Our automated iOS tests have started failing, yet our logic hasn’t changed. I can’t identify the cause yet, but something’s definitely off.

When the iOS application loads a dialog message "[The app] Would Like to Send You Notifications (Don’t Allow, Allow). Before I can communicate with it a second dialog appears "Allow [The App] to use your location? (Allow Once, Allow While Using App, Don’t Allow) For some reason I’m unable to communicate to this 2nd dialog. I wonder if it’s because the 1st dialog is still up behind. Nothing has changed in any of my settings and this started happening around the 18th.

Anyone else see this issue? Something is fishy.

There is new contact dialog im ios18 Find a better method to handle com.apple.ContactsUI.LimitedAccessPromptView bundle id automatically since iOS 18 contacts permission · Issue #20591 · appium/appium · GitHub

Other alerts I did not see difference. Why you cant accept first alert that in foreground and after second?

I’m not sure why I can’t communicate with the 2nd dialog. I was able to remove that dialog by disabling the Location Alerts under privacy & security. However I still notice a dialog appear and get overlapped by another. I was able to communicate top alert in this situation using. iosdriver.swithTo().alerts.accept(); However when I attempted to create a new user in the app if brought up that I needed to enable access in Settings. I was able to select “Allow While Using App” in the settings, but I wasn’t able to get back to the app. There is a link in the navigate bar to get back to the app, but for some reason I’m unable to click on it. I’ve tried used the coordinates of and that also failed. Got any other suggestions?

i use code

    @Step("Tap 'Accept permissions' button")
    public boolean tapAcceptPermissionsButton() { // iOS only
        Logger.log();
        final String iosLocator = "**/XCUIElementTypeButton[`name == \"Allow While Using App\" OR name == \"Allow\"`]";
        boolean bool = false;

        // https://appium.github.io/appium-xcuitest-driver/7.3/reference/settings/
        try {
            driver.setSetting("acceptAlertButtonSelector", iosLocator);
            driver.switchTo().alert().accept();
            bool = true;
        } catch (Exception ignored) {
        }
        return bool;
    }

plus maybe you have half modal dialog?

I was using this to communicate to the dialog. I inserted your method and it worked. Thanks you very much Aleksel.

if(iosdriver.findElement(By.id(“Allow While Using App”)).isDisplayed())
{
iosdriver.findElement(By.name(“Allow While Using App”)).click();
}

Solution:
final String iosLocator = “**/XCUIElementTypeButton[name == \"Allow While Using App\" OR name == \"Allow\"]”;
boolean bool = false;

    // https://appium.github.io/appium-xcuitest-driver/7.3/reference/settings/
    try {
        driver.setSetting("acceptAlertButtonSelector", iosLocator);
    } catch (Exception ignored) {
    }
    try {
        driver.switchTo().alert().accept();
        bool = true;
    } catch (Exception ignored) {
    }