How to handle geolocation pop up

Hi I have tried to use WebUI.alert / dismiss to handle the geolocation alert but the error message return “alert not found”. The alert is actually there.

I have googled and fond some other solutions, such as:

  1. Use selenium library, Alert alert = driver.switchTo().alert();
  2. create java.robot instance, rb.keyPress(KeyEvent.VK_D); rb.keyRelease(KeyEvent.VK_D);

None of these work. I have double check the import package. I can disable the popup from browser setting or disable pop up on desired capabilities.

Can you please advise other wiser way to do so?

The best way to handle this (assuming that it is indeed a browser-level notification) is withe Desired Capabilities. I’ve written a guide on how to determine which one to add:

Thanks for your solution @Brandon_Hein

I haven’t tried it yet. Shall
But why The WebUI.accpetAlert() does not work?

I tried to call selenium library and the java.robot. Why these both do not work??

Can I set desired capabilities on safari as well? same format?

I set the same args as chrome on safari. And the Browser is opened with “null” url.

Can you advise how to set up?