6

How can I click "Allow" in the pop up using Selenium with java? There is no way to inspect this pop up so I don't know the id, or name or xpath.

enter image description here

6 Answers 6

3

This is not an alert. This is a browser level notification.

Try these:

  1. How to handle browser level notification using Selenium Webdriver

  2. How to Disable Chrome notifications popup in Selenium WebDriver

1

Use below code to allow :

driver.switchTo().alert().accept(); //This will allow the access

To block the access use below code :

driver.switchTo().alert().dismiss();
2
  • Thank you but is not working, I tried allowing that is what I need and the pop up is being displayed and in the Eclipse console I am receiving this message: Exception in thread "main" org.openqa.selenium.NoAlertPresentException: no alert open (Session info: chrome=66.0.3359.181) (Driver info: chromedriver=2.37.544337 (8c0344a12e552148c185f7d5117db1f28d6c9e85),platform=Mac OS X 10.13.4 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:08.63
    – ArturoM
    May 30, 2018 at 12:12
  • Yes this is not a alert. try the below comment May 30, 2018 at 13:09
0

There is currently no support for permissions prompts in WebDriver, though there is a draft of an endpoint to control them (as of writing, I believe no WebDriver implementation exposes them, and there is no Selenium API for them).

0

Firefox profiles are to blame. I suggest creating and configuring a profile for Selenium to use that suits your needs.

See: https://stackoverflow.com/questions/21310797/using-selenium-webdriver-and-python-how-do-i-suppress-the-prompt-to-share-my-ca

0

Try this:

Robot robot = new Robot();
robot.delay(5000);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyPress(KeyEvent.VK_ENTER);

Hope this will help you.

0

This works like a charm for me. But I know this is not the right way of doing it.

        Robot robot = new Robot();
        robot.delay(3000);
        robot.keyPress(KeyEvent.VK_TAB);
        robot.keyPress(KeyEvent.VK_ENTER);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.