2

如何使用 webdriver+java 阻止所有弹出窗口?我知道如何处理弹出窗口,但我根本不想弹出,我想阻止所有弹出窗口,就像浏览器中的弹出窗口阻止程序一样......

4

2 回答 2

4
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("dom.popup_maximum", 0);
profile.setPreference("privacy.popups.showBrowserMessage", false);
FirefoxDriver fd = new FirefoxDriver(profile);
fd.get("http://example.com");
于 2016-11-11T11:23:04.013 回答
-1

尝试

fp = webdriver.FirefoxProfile()
fp.set_preference("privacy.popups.disable_from_plugins", 3)

阻止所有插件弹出窗口。

有关其他选项,请参阅https://superuser.com/questions/697018/how-to-disable-popups-in-firefox-without-add-ons

于 2016-02-13T17:31:20.870 回答