Enable Firefox Popup Blocking using C# and Selenium

Viewed 152

I'm using the Selenium 3.14 Webdriver to test a site with Firefox. (I test other browsers also - but this problem is with Firefox).

For some tests I want to enable popup blocking. My Firefox instantiation is:

driver = new FirefoxDriver(geckodriverDirectory);
driver.Manage().Timeouts().PageLoad = TimeSpan.FromMinutes(1.0d);

I tried adding an option, as follows:

var options = new FirefoxOptions();
options.SetPreference("disable-popup-blocking", false);
driver = new FirefoxDriver(driverDir, options);
driver.Manage().Timeouts().PageLoad = TimeSpan.FromMinutes(1.0d);

But that failed to enable popup blocking. Any ideas for setting the correct Firefox option?

1 Answers

I finally solved this by setting the following preference instead of the preference shown above:

   options.SetPreference("dom.disable_open_during_load", true);

The true value seems counter intuitive - because the impact is to have popup blocking enabled - but it works.

It would be great if Firefox would publish a list of preferences that their webdriver recognizes.

Related