How to accept "Allow app to access location" on Android?

Hi,

I’ve tried to locate “Allow” button on pop up window on Android to allow app to access location, but I’m having problem with it.
All I can access from this pop up is id “com.android.packageinstaller:id/permission_message” with text “Allow Matchbook to access this device’s location?”

I’ve also tried “self.driver.find_element_by_link_text(“Allow”)”, “self.driver.switch_to_alert()”, “self.driver.switch_to.alert()”
but nothing of these work.

I’m using:
Appium 1.2.6
Python 2.7
Galaxy Nexus emulator
Android OS 6.0
Appium webdriver (from appium import webdriver)

Is there any way to locate this element?

Thanks.

Hi can you try these two variations:

V1:

alert = self.driver.switch_to_alert()
alert.accept()

V2:

self.driver.switch_to_alert()
el = self.driver.find_element('Allow Matchbook to access this device’s location?')
el.click()

@Venkatesh_Akula thanks, I’ve tried that also, but it didn’t work.

But finally I got it working, I’ve found answer on stackoverflow: https://stackoverflow.com/questions/40122571/cant-click-allow-button-in-permission-dialog-in-android-using-appium/47177789#47177789

In my python code it looks like this:

self.driver.find_element_by_id(‘com.android.packageinstaller:id/permission_allow_button’).click()

@mate_xanadu try advanced interactions

let us know if it helped