问题
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