PFB the code:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); //Name of mobile web browser to automate. Should be an empty string if automating an app instead.
capabilities.setCapability(CapabilityType.VERSION, "6.0");
capabilities.setCapability(CapabilityType.PLATFORM, "Android");
capabilities.setCapability("deviceName", <deviceID>);
capabilities.setCapability("locationServicesAuthorized", true);
capabilities.setCapability("appPackage",<Package Name for app under test >); //Replace with your app's package
capabilities.setCapability("appActivity",<Activity Name for app under test >); //Replace with app's Activity
driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
When the app under test gets launched for the first time, it displays a Location permission popup.
The resource id for popup element is:
com.android.packageinstaller:id/dialog_container
which is outside package of app under test.
We are able to detect the elements of App permission pop up using uiAutomatorViewer.
But, we are unable to run script using the same element ids as those are not getting detected through the script.
We tried using below code:
**capabilities.setCapability("autoAcceptAlerts", true);**
This is not working.
We have even tried using:
driver.switchTo().alert().accept();
This also is not working.
Any suggestions will be appreciated.