gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:29:12 28 6
gpt4 key购买 nike

每次我进入新的 IE 浏览器以运行处理弹出窗口处理的 Selenium 自动化脚本时,我都需要从 IE 设置中手动禁用弹出窗口阻止程序选项。有没有办法通过使用某些功能或其他东西以编程方式禁用 IE 弹出窗口阻止程序?

最佳答案

我们必须修改注册表值才能在 IE 中操作弹出窗口阻止程序。注册表信息如下:

注册表位置: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows

注册表值名称: PopupMgr

注册表值数据:否 [关闭弹出窗口阻止程序]是 [打开弹出窗口阻止程序]

如果您正在使用 Java 并希望以编程方式实现它,以下代码片段一定会对您有所帮助:

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!");
}

希望对您有所帮助!

关于java - IE + Selenium : Is there any way to disable pop-up blocker programmatically in IE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22012076/

28 6 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com