[Trouble Shooting 101] Firefox Alert Is Not Popping Up During Automation

Issue
While running automation tests, the expected browser alert does not appear in Firefox, even though it works in other browsers.

Root Cause
In Firefox, the preference dom.disable_beforeunload is set to true by default.
This blocks beforeunload alerts from being displayed.

Solution
You need to explicitly set the Firefox preference dom.disable_beforeunload to false before launching the browser.

Example (Katalon + Selenium):

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

WebDriver driver = new FirefoxDriver(firefoxOptions);
driver.navigate().to(url);
DriverFactory.changeWebDriver(driver);

} else {
WebUI.openBrowser(url);
}

Important Note
Setting this via Desired Capabilities in Katalon does not work for Firefox, because the FirefoxDriver constructor only accepts FirefoxOptions.

Takeaway
If Firefox alerts are not appearing:

  • Check the dom.disable_beforeunload preference
  • Use FirefoxOptions instead of Desired Capabilities

Hope this helps anyone facing the same issue :+1:

Enjoy testing

2 Likes

nice information !

1 Like

good one for beginners!!

1 Like

just sharing a few additional things that might be worth checking:

  • first, make sure it’s a real browser alert, not a custom modal (SweetAlert, Bootstrap, etc.). Selenium/Katalon can’t handle those with switchTo().alert()
  • check timing issues. In Firefox, alerts can appear very briefly. Using WebUI.waitForAlert() or adding a short explicit wait often helps
  • try running with a fresh Firefox profile. Reused profiles or extensions can sometimes suppress alerts
  • if the alert is triggered after a frame or window change, double-check you’re in the correct frame/window context
  • test the same flow in a minimal script. If it works there, the issue is usually related to the test flow, not the alert itself
  • also worth checking Firefox, GeckoDriver, and Katalon version compatibility, especially if it works in Chrome but not Firefox
1 Like