In my project I am getting the below alert in IE after navigating to the Location tab.
Now I would like to accept the same and for that I had added the below capabilities but it is not working.
System.setProperty("webdriver.ie.driver",properties.getProperty("InternetExplorerDriverPath"));
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability("nativeEvents", true);
ieCapabilities.setCapability("window.confirm", true);
ieCapabilities.setCapability("unexpectedAlertBehaviour", "accept");
ieCapabilities.setCapability("disable-popup-blocking", true);
ieCapabilities.setCapability("enablePersistentHover", true);
driver = new InternetExplorerDriver(ieCapabilities);
Please help.
I am unable to open the url. In such cases in IE browser, ALT+N
command will shift the focus to the alert pop up in the bottom of the page.
So, you can use a Robot
class and send ALT+N
keys to shift the focus to the alert pop up and then you can pass TAB
keys and select the required options (i.e. to Allow Once or select other options).
Sample Example:
Robot robo=new Robot();
robo.keyPress(KeyEvent.VK_ALT);
robo.keyPress(KeyEvent.VK_N); //this will move the focus to alert pop up
//play around with other keys once the foucs moves to the alert pop up
//ensure to release all the keys
Note: Check if ALT+N
command shifts the focus to the alert pop up manually and then try using selenium