Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE + Selenium : Is there any way to disable pop-up blocker programmatically in IE

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?

like image 435
Sitam Jana Avatar asked Feb 25 '14 10:02

Sitam Jana


People also ask

Can we handle Windows popup using Selenium?

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.


1 Answers

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!

like image 199
Sitam Jana Avatar answered Oct 30 '22 15:10

Sitam Jana