Skip to main content

Firefox Browser Alert is not getting popped up

Last updated: September 2025

During automation testing, the expected alert is not getting popped up in Firefox browser.

By default the preference variable dom.disable_beforeunload has the value true which blocks the popup.

We need to set the value of preference variable dom.disable_beforeunload to false before launching the Firefox browser.
String browser = DriverFactory.getExecutedBrowser().getName()
    if (browser.equalsIgnoreCase('FIREFOX_DRIVER')) {              
      System.setProperty("webdriver.gecko.driver", 
        DriverFactory.getGeckoDriverPath());
      FirefoxOptions firefoxOptions = new FirefoxOptions();
      firefoxOptions.addPreference("dom.disable_beforeunload", false);  // only for firefox browser special preference is needed.
      WebDriver driver = new FirefoxDriver(firefoxOptions);
      driver.navigate().to(url);
      DriverFactory.changeWebDriver(driver)
    }else {
      WebUI.openBrowser(url)
    }
Here the desired capabilities option in Katalon doesn't work because the constructor of the Firefox driver accepts only Firefox options as input.
Was this page helpful?