Each time I move into new IE browser to run Selenium automation scripts which deals with pop-up handling, I need to disable pop-up blocker option from IE settings manually. Is there a way to disable IE pop-up blocker programmatically by using some capability or something?
Yes, it is possible to handle Windows based pop-ups in Selenium webdriver. Sometimes on clicking a link or a button, another window gets opened. It can be a pop up with information or an advertisement. The methods getWindowHandles and getWindowHandle are used to handle child windows.
We have to modify Registry value to be able to manipulate pop-up blocker in IE. Registry information is given below:
Registry Location: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows
Registry Value Name: PopupMgr
Registry Value Data: no [Turn off pop-up blocker] and yes [Turn on pop-up blocker]
If you are with Java and want to achieve it programmatically, following code snippet will surely help you:
String cmd = "REG ADD \"HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\New Windows\" /F /V \"PopupMgr\" /T REG_SZ /D \"no\"";
try {
Runtime.getRuntime().exec(cmd);
} catch (Exception e) {
System.out.println("Error ocured!");
}
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With