Android M and permissions

yea tried changing the capability settings as per Android 6.0 also. But getting the same error.

you have 2 device connected. may you remove 1 and try both again?

Still no luck after connecting with a single device.

We’ve added a simple while loop in our framework to the method that looks up elements:

while(autoAcceptPerms && _driver.currentActivity().contains(“GrantPermissionsActivity”)){
_driver.findElement(By.id(“com.android.packageinstaller:id/permission_allow_button”)).click();
}

The autoAcceptPerms boolean is configurable by constructor. This results in permission dialogs to be immediately accepted when they appear.

I think it is simpler if you grant the permissions with adb before starting the app.

subprocess.Popen("adb shell pm grant <package name> android.permission.ACCESS_FINE_LOCATION", shell=True).communicate()
1 Like

with latest 1.6.3 Appium use:

capabilities.setCapability(“autoGrantPermissions”, “true”);

1 Like

@Aleksei

I am using appium 1.6.3 on Android M and using …

capabilities.setCapability(“autoGrantPermissions”, “true”);

I’m launching chrome but the permission pop ups are still occurring.

I am with native client. With chrome not tested.

We can check that the element is available or not by using:
driver.checkVisibility(“String Id”);
Then click on the buttons if the pop up is available.

thanks it works for me :slight_smile:

The following capabilities were provided, but are not recognized by appium: autoGrantPermissions

I have Appium 1.6.3
AndroidDriver version: 1.10.38 - I found latest version is https://github.com/appium/appium-android-driver 1.17.1 but in the Android AndroidMobileCapabilityType still are not autoGrantPermissions
I have java-appium-client-4.1.2.jar latest seems to be https://github.com/appium/java-client 5.0.0-BETA7 but again I didnt see autoGrantPermissions in the AndroidMobileCapabilityType

So what do I need to update to get Appium to recognize the autoGrantPermissions ?

I have used the capabilities u hv given for android 6 still it is giving error, please guide

@dhananjay

  1. enable debug appium log and check that grant permission command passes to device
  2. check on device what permissions are given
  3. double check that you see permission dialog not your app custom dialog

checked all the 3 points u have mentioned still not working…please guide

@dhananjay you checked but do not know the result of each check :slight_smile: can you tell little bit more result with each step…

1)enable debug appium log and check that grant permission command passes to device
= i have enabled the developer settings and given nodejs port number the same i hv used ,after that i have started the node server

2)check on device what permissions are given
=applications permissions are contacts,locate,phone and storage which i have kept off

3)double check that you see permission dialog not your app custom dialog
=yes i am getting the permissions dialog
above points i have checked if anything is missing please guide
what i have to operate and what error i am getting please refer this link i have uploaded the pics also …

thanks for your quick response

refer link:How to select allow option please guide

@dhananjay with first i mean APPIUM server logs. make them to DEBUG level. check that you can find following lines in logs when driver start:

  1. “autoGrantPermissions: ‘true’”
2017-08-31 11:52:24:749 - [Appium] Capabilities:
....
2017-08-31 11:52:24:753 - [Appium]   autoGrantPermissions: 'true'
...
2017-08-31 11:52:24:754 - [Appium]   platformName: 'Android'
  1. depending on permiisions needed log can change:
2017-08-31 11:52:30:918 - [debug] [ADB] Running '/Users/Aleksei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","LGH8155e9892e6","shell","pm","dump","io.appium.settings"]
2017-08-31 11:52:31:901 - [debug] [ADB] Got the following command chunks to execute: pm,grant,io.appium.settings,android.permission.WRITE_SETTINGS,;,pm,grant,io.appium.settings,android.permission.ACCESS_MOCK_LOCATION,;
2017-08-31 11:52:31:901 - [debug] [ADB] Getting connected devices...
2017-08-31 11:52:31:933 - [debug] [ADB] 1 device(s) connected
2017-08-31 11:52:31:934 - [debug] [ADB] Running '/Users/Aleksei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","LGH8155e9892e6","shell","pm","grant","io.appium.settings","android.permission.WRITE_SETTINGS",";","pm","grant","io.appium.settings","android.permission.ACCESS_MOCK_LOCATION",";"]
2017-08-31 11:52:33:097 - [debug] [ADB] Getting connected devices...
....
2017-08-31 11:53:04:704 - [debug] [ADB] Running '/Users/Aleksei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","LGH8155e9892e6","shell","pm","dump","ee.zzzz.zzzz"]
2017-08-31 11:53:05:584 - [debug] [ADB] Got the following command chunks to execute: pm,grant,ee.zzzz.zzzz,android.permission.READ_CONTACTS,;,pm,grant,ee.zzzz.zzzz,android.permission.READ_PHONE_STATE,;,pm,grant,ee.zzzz.zzzz,android.permission.GET_ACCOUNTS,;,pm,grant,ee.zzzz.zzzz,android.permission.WRITE_EXTERNAL_STORAGE,;,pm,grant,ee.zzzz.zzzz,android.permission.CAMERA,;,pm,grant,ee.zzzz.zzzz,android.permission.READ_EXTERNAL_STORAGE,;
2017-08-31 11:53:05:584 - [debug] [ADB] Getting connected devices...
2017-08-31 11:53:05:599 - [debug] [ADB] 1 device(s) connected
2017-08-31 11:53:05:599 - [debug] [ADB] Running '/Users/Aleksei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","LGH8155e9892e6","shell","pm","grant","ee.zzzz.zzzz","android.permission.READ_CONTACTS",";","pm","grant","ee.zzzz.zzzz","android.permission.READ_PHONE_STATE",";","pm","grant","ee.zzzz.zzzz","android.permission.GET_ACCOUNTS",";","pm","grant","ee.zzzz.zzzz","android.permission.WRITE_EXTERNAL_STORAGE",";","pm","grant","ee.zzzz.zzzz","android.permission.CAMERA",";","pm","grant","ee.zzzz.zzzz","android.permission.READ_EXTERNAL_STORAGE",";"]
2017-08-31 11:53:09:474 - [debug] [ADB] Getting connected devices...
2017-08-31 11:53:09:490 - [debug] [ADB] 1 device(s) connected

you can also try to execute this manually to check if it grant any permission