I am unable to tap on Deny or Allow buttons on the permissions dialog in Android using Appium+Java. Do I need to add any capabilities before going to tap on those buttons? Below
Appium gives you an API that detect the activity. Depending upon your device, you could get two activities - the package name may get stripped off or not:
'com.android.packageinstaller.permission.ui.GrantPermissionsActivity',
'.permission.ui.GrantPermissionsActivity'
After detecting this activity, you need to find an element by locator(id/xpath):
'com.android.packageinstaller:id/permission_message'
Then you can obtain the text of that message if you are interested in it. If you care which permission it is, you can match it against expected strings or regular expressions. If not, you can blindly accept by finding and clicking the element by id:
'com.android.packageinstaller:id/permission_allow_button'
If you'd rather not click 'allow' on all those windows, you can use adb to add all the permissions at once before you start testing (but after Appium has installed your app). If you know all the perms your app will need, you can add them with one command:
pm grant $app_name $space_delimited_set_of_perms
Or you can add all permissions one at a time, which takes 1.5-2 seconds per attempt.
Reference : https://discuss.appium.io/t/android-m-and-permissions/5760/13