Marshmallow run time permissions

Hi everyone, am beginner to automation please help me on following issue

Marshmallow run time permissions:

Script freezes once permission messages(XYZ app want to access media files,gallery images) popup.
How to resolve this issue ?

@priyanka1 with driver just add:

capabilities.setCapability("autoGrantPermissions", "true");
1 Like

Thank you Aleksei.

I tried same but yet am facing same.

then it should be your custom app alert.

Can you please check this error,

INFO: Detected dialect: OSS
Exception in thread “main” org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)

@priyanka1 just element not found. pls give screenshot.

if you found the answer to your question then can you please tell me?

if it our custom app alert then what can i do to grant permission to it? Do you know how to do it?

@Monis if you set “autoGrantPermissions” = true then this permission will not appear. Otherwise this is custom alert of you app and you should accept it in code manually.

1 Like

@Aleksei
capabilities.setCapability(“autoGrantPermissions”, “true”);
i used the same above code. but still it shows the run time permissions.
and the dialog is not custom, its the default permission asking dialog.

Please help

@Jassi_Kaushik hardly believe. Can you check following:

  1. just start your driver with this capability and finish test
  2. on phone check in app settings are any permissions where given.

@Aleksei
Thanks for the repl.
yes i do the same… start the driver with the capability and finish the test.
The App has been development by me only. I gave read sms permissions.

Still it shows the dialog even after write capabilities.setCapability(“autoGrantPermissions”, “true”);

i am new to Appium . please see the following code for initialise the driver.

            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
            capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "XOLO");
            capabilities.setCapability(MobileCapabilityType.APP, "path of my apk");
            capabilities.setCapability("unicodeKeyboard", "false");
            capabilities.setCapability("resetKeyboard", "true");
            capabilities.setCapability("locationContextEnabled", "true");
            capabilities.setCapability("databaseEnabled", "false");
            capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, "pkg name of my app");
            capabilities.setCapability("noReset", "true");
            capabilities.setCapability("autoAcceptAlerts", true);
            capabilities.setCapability("autoDismissAlerts", true);
            capabilities.setCapability("autoGrantPermissions", "true");
            driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);

looks good. maybe one line can be better:

capabilities = DesiredCapabilities.android();

i replaced DesiredCapabilities capabilities = new DesiredCapabilities(); with capabilities = DesiredCapabilities.android();. still the problem persists.
It shows permission dialog again. please guide… any change i need to do??

ok. try to enable debug appium logging and check what ADB command sending to grand permissions.

@Aleksei
Thanks . but i checked the logs.ADB is sending no command to grand permissions.
its weird. if i write code for autoGrantPermissions then why it doesnt send??

@Jassi_Kaushik so you can send it manually and check what/why permission do not work with your app

@Aleksei
sorry didnt get it. do you mean , give permissions while installing app through command prompt??

All manually.

  1. uninstall app
  2. install app via adb command
  3. repeat appium command grand permissions
  4. check result in application manager. Was permissions granted.

Check in web search for sure that grand permissions command is correct.

Have Appium automatically determine which permissions your app requires and grant them to the app on install. Defaults to false . If noReset is true , this capability doesn’t work.