autoAcceptAlerts: true clears all alerts when testing the app?

When the app is launched the first time, due to the alerts not being dismissed the app would crash. Adding autoAcceptAlerts: true in the capabilities fixed it for us.

What I now see is that all alerts in the app get auto accepted. Like a delete confirmation or invalid text alert etc.

Is this expected behavior? If yes, is there a work around or a better way to dismiss initial pop ups so I can still continue accept/decline the app related alert and pop ups?

Once you set autoAcceptAlerts to true… .all upcoming alerts irrespective of app of device will be accepted.

Its better to handle it in code.

1 Like

I agree with @Mobile_Test_Test, the other suggestion is to set the autoAcceptAlerts to false after you dimissed the first popup.

1 Like


It is something new to me a parameter which we pass while desired capabilities while creating HTTP session, how we can override it in same HTTP session once session is created.

like first i told appium server to set autoAcceptAlerts = true and then after some time I set it autoAcceptAlerts =false in same session

can u share how we can do it in code ???


I dont recommend my own suggestion. You should take the route @Mobile_Test_Test suggested and which I agreed on. Because that is the right route to take in the long run.

Thanks all for your replies.

When the driver gets initialized I pass
autoAcceptAlerts: true and this works for me to accept system alerts. Once the app is successfully launched and the alerts are accepted, i try to use this before my test begins
$appiumDriver.update_settings({autoAcceptAlerts: false})

Is this the correct syntax? Or does anyone have a working example for this?

Appium logs:

info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“ELEMENT”:“0”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“0”},“sessionId”:“e079a84b-a534-4434-8ca5-5269166f2b13”}
info: <-- POST /wd/hub/session/e079a84b-a534-4434-8ca5-5269166f2b13/element 200 6555.198 ms - 87 {“status”:0,“value”:{“ELEMENT”:“0”},“sessionId”:“e079a84b-a534-4434-8ca5-5269166f2b13”}
info: --> POST /wd/hub/session/e079a84b-a534-4434-8ca5-5269166f2b13/appium/settings {“settings”:{“autoAcceptAlerts”:false}}
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“e079a84b-a534-4434-8ca5-5269166f2b13”}
info: <-- POST /wd/hub/session/e079a84b-a534-4434-8ca5-5269166f2b13/appium/settings 200 5.426 ms - 76 {“status”:0,“value”:null,“sessionId”:“e079a84b-a534-4434-8ca5-5269166f2b13”}
info: --> POST /wd/hub/session/e079a84b-a534-4434-8ca5-5269166f2b13/appium/settings {“settings”:{“autoAcceptAlerts”:false}}
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“e079a84b-a534-4434-8ca5-5269166f2b13”}
info: <-- POST /wd/hub/session/e079a84b-a534-4434-8ca5-5269166f2b13/appium/settings 200 2.370 ms - 76 {“status”:0,“value”:null,“sessionId”:“e079a84b-a534-4434-8ca5-5269166f2b13”}
info: --> GET /wd/hub/session/e079a84b-a534-4434-8ca5-5269166f2b13/source {}

dont enable autoAcceptAlerts if all you want is to accept a pop up at app launch.

Instead add this to to your capabilities,

"waitForAppScript": "$.delay(8000); $.acceptAlert();"
1 Like

How can I do this using JavaScript?


driver. execute script() use this method to execute js scripts using appium

Please tell me how can i use this using Java.

This is a parameter that is part of your capabilities. It has nothing to do with what language you use.

1 Like

See here for an example:

1 Like

So how can I make this true while running the app on simulator as well as code using java

    down vote

Thanks for the same…

But after accepting the alert. I am unable to go back to the app after accepting the alert

Getting this error:
Exception in thread “main” org.openqa.selenium.NoAlertPresentException:
An attempt was made to operate on a modal dialog when one was not open.
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.35 seconds

So how could I go back to the app after accepting the alert?

Any idea about the syntax in ruby for auto accepting the initial app permissions for android M?

My current desired capabilities is

 require "appium_lib"

def caps
      caps:{ deviceName: "Samsung",
             platformName: "Android",
             app: (File.join(File.dirname(__FILE__), "abs.apk")),
             Packagename: "",
             newCommandTimeout: "3600",
             autoAcceptAlerts: "true",
             appium_lib: { wait: 20,
                           debug: false,

def server_url
end   #Pass capabilities for appium inside the driver
Appium.promote_appium_methods Object #Makes all appium_lib methods accessible from steps

How to do this? once after driver is set to launch the app same driver will be used in further cases right? where and how can i reinitialize it .Please help