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.
If you want to allow all the permissions to the app you are going to install, then you can auto grant all the permissions through DesiredCapability.
capabilities.setCapability(“autoGrantPermissions”, true);
This will not open the permission popup when the app is installed and launched.
Hi @Rohan1808 i have used this code but after giving permissions my code is not working for further steps and even in console i am not getting any error , do i need to change view after giving permissions
Hi
I used the following capabilities in my appium code but still my location pop is not disappearing.
caps.setCapability(“enablePerformanceLogging”, true);
caps.setCapability(“autoGrantPermissions”,true);
caps.setCapability(“extendedDebugging”, true);
caps.setCapability(“locationContextEnabled”, true);
caps.setCapability(“autoAcceptAlerts”, “true”);
caps.setCapability(“locationServicesAuthorized”, false)