Handling the Location Sharing Popup In Chrome Browser

Environment :

          Appium Java Client
          Real Device

Issue : I am not able to accept or deny the location sharing popup (below image)

Below is the Accept button properties in Native Context .

I tried to change context to Native and tried to click on the accept button by doing driver.findElement(By.id(“com.android.chrome:id/button_primary”)).click();
but I am getting no such element exception. However i am able to click on the chrome URL by the same method.

I tried to get the Alert driver.switchTo().alert().dismiss() but i am getting No Such Alert Exception.

I tried to get the window handlers also but i am getting only one handler.

Is there any way i can click on the Accept Button ? [ Let me know if any one reqire any additional details ]

I haven’t found any way to accept the alert but you can use selenium navigate method to dismiss/hide it.


Nope. :frowning: The navigation also not dismissing the alert.

Check this SO answer. It’s Python but it should be easy to translate into Java. You need to switch context to NATIVE_APP and then find ‘Allow’ or ‘Block’ button within the popup using following xpath expressions:


and click it.