How to Auto-Dismiss Location Permission Alerts in iOS Simulator Using Appium?

I’m facing an issue where I can’t allow the location permission on the simulator. I’ve tried the following method, but it only works on iOS 18:

I’m running tests on iOS Simulator using Appium, and my app triggers the standard location permission: “Allow Once” / “Allow While Using App” / “Don’t Allow”.
I’ve already tried setting these desired capabilities:

  • "autoAcceptAlerts": true
  • "autoDismissAlerts": true

But the alert is not dismissed automatically. I also tried locating the alert buttons manually using XPath or accessibility ID, but the elements are not visible or interactable through Appium.

Is there a reliable way to auto-dismiss or bypass this alert during automation on iOS simulators?
I’m currently using: Appium 2.19.0, iOS 18.4 Simulator.

Any suggestions or best practices would be appreciated.

I prefer to dismiss manually on screen where they could be.
To dismiss manually → [IOS] [REACT-NATIVE APP] With latest appium, not able to interact with the alert text boxes like permissions - #2 by Aleksei

BTW contact permission is other story starting iOS18 ! → Troubleshooting - Appium XCUITest Driver

Thank you for your reply. I tried to recreate your code in Python, but I’m getting an error: :cross_mark: Failed to set acceptAlertButtonSelector: 'WebDriver' object has no attribute 'set_settings'. Do you know why this is happening and how to fix it?

def accept_ios_location_alert():
    success = False

    try:
        appiumlib = BuiltIn().get_library_instance('AppiumLibrary')
        driver = appiumlib._current_application()
        print(f"{driver}")
    except Exception as e:
        print(f"❌ Failed: {e}")
        return False

    try:
        selector = "**/XCUIElementTypeButton['name == \"Allow While Using App\" OR name == \"Allow\"']"
        driver.set_settings({
            "acceptAlertButtonSelector": selector
        })
        print(f"✅ Setting 'acceptAlertButtonSelector' success di-set: {selector}")
    except Exception as e:
        print(f"❌ Filed set acceptAlertButtonSelector: {e}")
        return False

    time.sleep(3)

    try:
        alert = driver.switch_to.alert
        alert_text = alert.text
        print(f"⚠️ Alert is appears: {alert_text}")
    except:
        print("✅ Alert success dismiss.")
        success = True

    return success
driver.set_settings -> driver.set_setting OR self.driver.set_settings({"acceptAlertButtonSelector": ios_locator})
driver.switch_to.alert -> driver.switch_to.alert.accept()

I have already tried as you suggested, but the same error still occurs. May I know which versions of Xcode, XCTest, and Appium you are using?

appium -v
2.17.1
appium driver list
✔ Listing available drivers
- [email protected] [installed (npm)]
- [email protected] [installed (npm)]

but in your case problem in python library i guess.

Write again new error you have after code changed.

when i used driver.set_setting → Im getting error

set acceptAlertButtonSelector: ‘WebDriver’ object has no attribute ‘set_setting’

and self.driver.set_settings → getting error

set acceptAlertButtonSelector: ‘WebDriver’ object has no attribute ‘set_settings’
this is full code after changes

from robot.libraries.BuiltIn import BuiltIn
from AppiumLibrary import AppiumLibrary
import time

class IOSPermissionLibrary:

    def accept_ios_location_alert_permission(self):

        self.appiumlib = BuiltIn().get_library_instance('AppiumLibrary')
        self.driver = self.appiumlib._current_application()
        success = False

        try:
            print(f"Driver instance: {self.driver}")
        except Exception as e:
            print(f"❌ Failed to get driver: {e}")
            return False

        try:
            selector = "**/XCUIElementTypeButton['name == \"Allow While Using App\" OR name == \"Allow\"']"
            self.driver.set_settings("acceptAlertButtonSelector", selector)
            print(f"✅ Setting 'acceptAlertButtonSelector' successfully set: {selector}")
        except Exception as e:
            print(f"❌ Failed set acceptAlertButtonSelector: {e}")
            return False

        time.sleep(3)

        try:
            self.driver.switch_to.alert.accept()
            print("✅ Alert Successfully .")
            success = True
        except Exception as e:
            print(f"❌ Failed alert: {e}")

        return success

mmmmmm possibly python Appium client just does not support it… try create ticket → GitHub · Where software is built

okay, thank you for your help. I already create ticket Im getting an error: WebDriver' object has no attribute 'set_settings · Issue #1145 · appium/python-client · GitHub

changed to update_settings!
try with

self.driver.update_settings({"acceptAlertButtonSelector": ios_locator})

in doc mentioned wrong link to settings. new one → appium/packages/appium/docs/en/guides/settings.md at master · appium/appium · GitHub