How to block all pop ups using webdriver?

馋奶兔 提交于 2020-02-02 12:03:07

问题


How to block all pop ups using webdriver+java? I know how to handle pop ups but i don't want pop up at all, i want to block all the pop ups just like a pop up blocker in a browser...


回答1:


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



回答2:


Try

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

to block all plugin popups.

See https://superuser.com/questions/697018/how-to-disable-popups-in-firefox-without-add-ons for other options.



来源:https://stackoverflow.com/questions/14201949/how-to-block-all-pop-ups-using-webdriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!