How to handle iOS send notification popup

When I run the below code the notification
iOS notification popup is display & then the test is failing before i can handle the popup (pressing the OK button).
Any suggestion how to either avoid the popup or code handle the exception?
Thanks! in advance…

driver = new IOSDriver(new URL(“http://127.0.0.1:4723/wd/hub”),capabilities);

The Popup:

Please try
capabilities.setCapability(“autoAcceptAlerts”,true);

This will accept the Alerts .
But If you use EventfiringWebdriver it can be handled in onAlert() section.

Thanks
Asit

3 Likes

Thanks!!!
It helped.

Is it possible to enable / disable it autoAcceptAlerts during run time?
At one point I want to enable this capability.
Is it possible without initiate the driver (I don’t want that the test will stop running when disable / enable this capability)?
Thanks again for the help!

Using driver capability i think NO as it will blindly accept or reject the pop up else you have some specific condition set to ignore a specific alert .

I am not sure in mobile testing but if you are using EventFiring driver in on Alert() you can adda if statement on alert text to ignore.

Sorry can not help much on this.

Add a sleep e.g. Sleep(5); in the actual source code and then build the app, the sleep is to be placed before the code that executes the Notification popup. This allows Appium to find the popup and the test will continue.

2 Likes

it is not working for me
in my case it appears before I even see my application installed
any idea?

It’s not working for me too

I bet the Notification in Appium Desktop will give an id for ok or Allow. Use this to target and click. Give a wait until the object shows. You can use auto allow or disallow in your Desired Capabilities.