Im getting an error: WebDriver' object has no attribute 'set_settings

I’m facing an issue where I can’t allow the location permission on the simulator. I tried using python. But Im getting error acceptAlertButtonSelector : 'WebDriver' object has no attribute 'set_settings. I’m currently using: Appium 2.19.0 , iOS 18.4 Simulator , Robot Framework 7.3.2, and Python 3.9.6.

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.execute_script("mobile: setSettings", {
        "settings": {
                "acceptAlertButtonSelector": selector
             }
         })
        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

Did you actually check the api ? There is no set_settings and thus you get “no attribute” error. Actual method you need to call is update_settings. See Location service popup - #3 by wreed - Support - Appium Discuss

1 Like