IE + Selenium:有什么方法可以在IE中以编程方式禁用弹出窗口阻止程序 [英] IE + Selenium : Is there any way to disable pop-up blocker programmatically in IE
问题描述
每次我进入新的IE浏览器以运行处理弹出处理的Selenium自动化脚本时,都需要从IE设置中手动禁用弹出窗口阻止程序选项.有没有一种方法可以通过使用某些功能或某些方式以编程方式禁用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?
推荐答案
我们必须修改注册表值,才能处理IE中的弹出窗口阻止程序.注册表信息如下:
We have to modify Registry value to be able to manipulate pop-up blocker in IE. Registry information is given below:
注册表位置: HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ New Windows
注册表值名称: PopupMgr
注册表值数据:否[关闭弹出窗口阻止程序] ,是[开启弹出窗口阻止程序]
如果您使用Java并希望以编程方式实现它,那么以下代码段肯定会为您提供帮助:
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!");
}
希望有帮助!
这篇关于IE + Selenium:有什么方法可以在IE中以编程方式禁用弹出窗口阻止程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!