How to close firefox browser in selenium 3.0.1

11k Views Asked by At

Firefox : 50.0.1, GeckoDriver :13, selenium 3.01, IDE: Eclipse, Programming language : Java

Using below code :

System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe); 
WebDriver driver = new FirefoxDriver();
driver.get("https://www.youtube.com/");
driver.close(); Or driver.quit()

In driver.close() the browser is not closed In driver.quite() the browser is closed and Firefox crashed. Getting Error: "plugin container for FireFox has stopped working."

Please let me know any solution

4

There are 4 best solutions below

5
Naveen Kumar R B On

Steps you can try:

  1. Uninstall any plugins in the Firefox browser.
  2. Use the 64-bit version of geckodriver for 64-bit Firefox, similarly, 32-bit geckodriver for 32-bit Firefox.

I have tried the code in the same environment, and driver.quit worked for me. driver.close still not closing the browser.

0
acikojevic On

You should always use driver.quit() when you want to close browser and not just one tab.

This exception you get is unfortunately known issue when quitting geckodriver firefox instance, see this links for details.

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/7506 https://bugzilla.mozilla.org/show_bug.cgi?id=1027222

0
Anand On

You can create a new firefox profile steps can be found here!

In your code use this new profile created.

WebDriver webdriver;
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("myProfileName");
webdriver = new FirefoxDriver(myprofile);

Now webdriver.quit(); will close the firefox browser after the test has run.

0
RubenD On

This seems to be a problem with the geckodriver.

The workaround which worked for me was to install the older version of geckodriver, 0.20.1, which you can download here: https://github.com/mozilla/geckodriver/releases/tag/v0.20.1