Search code examples
javaselenium-webdriverjunit4browser-automation

how to handle this particular popup..this occurs only in firefox


enter image description hereI am doing an automation learning project in this web site. https://www.shoppersstop.com/ and when using selenium Firefox browser, i got this particular popup.. i tried with firefox options to block it, but thats not working,, any help is appreciated...

System.setProperty("webdriver.gecko.driver", "src\\test\\resources\\drivers\\geckodriver.exe");
FirefoxOptions Options = new FirefoxOptions();
Options.addPreference("dom.disable_beforeunload", true);
driver = new FirefoxDriver(Options);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);][1]][1]
         
        

Solution

  • You can disable this with profile properties:

    FirefoxOptions Options = new FirefoxOptions();
    Options.addPreference("dom.disable_beforeunload", true);
    final FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("geo.enabled", false);
    profile.setPreference("geo.provider.use_corelocation", false);
    profile.setPreference("geo.prompt.testing", false);
    profile.setPreference("geo.prompt.testing.allow", false);
    options.setProfile(profile);
    driver = new FirefoxDriver(Options);