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.
6 Answers
This is not an alert. This is a browser level notification.
Try these:
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();
-
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– ArturoMCommented May 30, 2018 at 12:12
-
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).
Firefox profiles are to blame. I suggest creating and configuring a profile for Selenium to use that suits your needs.
Try this:
Robot robot = new Robot();
robot.delay(5000);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyPress(KeyEvent.VK_ENTER);
Hope this will help you.
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);