jjzjj

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

coder 2024-04-02 原文

每次我进入新的 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/

有关java - IE + Selenium : Is there any way to disable pop-up blocker programmatically in IE的更多相关文章

随机推荐