How to handle pop-ups in mobile apps

I am attempting to set up my first test, by logging into my app and then logging back out. After I log in, a pop up appears asking me to either confirm some information or “ask me later.” I’m using the Appium Desktop inspector to get the ID of the button in the popup, but nothing has seemed to work.
I’ve tried every findElementBy method, as well as the driver.switchTo().alert(). I have also added “autoGrantPermissions”, “true” and “autoAcceptAlerts”, “true” in my desired capabilities. How can I remedy this? Thanks!

Extra Notes:
-Using Appium Version 1.8.1
-Tests written in java (and all path variables have been set correctly)
-App in android and is being ran on an on Android Emulator
-I use macOS High Sierra

you can use uiautomatorviewer to capture the resource id or text attribute and then use click to handle the Alerts.

uiautomatorviewer comes with android sdk and is present in tools folder. I suggest capture the locator using a real device.

autoAcceptAlerts is deprecated.

1 Like


Thanks for the reply! I have tried using the UIAutomatorViewer to capture ID, class name, xpath, name, etc. to use the various findElementBy methods, but still nothing is allowing me to click on popup elements.

Here is the output I’m getting after running my test and the popup is unsuccessfully clicked:

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.base/java.lang.reflect.Constructor.newInstance(
at org.openqa.selenium.remote.ErrorHandler.createThrowable(
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(
at org.openqa.selenium.remote.HttpCommandExecutor.execute(
at io.appium.java_client.remote.AppiumCommandExecutor.execute(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at io.appium.java_client.DefaultGenericMobileDriver.execute(
at io.appium.java_client.AppiumDriver.execute(
at org.openqa.selenium.remote.RemoteWebDriver.findElement(
at io.appium.java_client.DefaultGenericMobileDriver.findElement(
at io.appium.java_client.AppiumDriver.findElement(
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(
at io.appium.java_client.AppiumDriver.findElementByXPath(

I have the same problem … I already tried by ID, Xpath, Class everything that is possible … By Ispector of Appium I can capture the element and click, playing the same code in ruby / cucumber does not work … says no able to locate the element.

Can anyone help? application was developed in IONIC with Angular