8

Environment: Win 7, Selenium 3.0.0 beta, FireFox- 49.0.1

System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe");

WebDriver driver=new FirefoxDriver();    

Issue 1:

Command: driver.close(); or ((FirefoxDriver) driver).kill();

Expected Result: Browser should close.

Actual Result: Browser is not closing.

Issue 2:

Command: driver.quit();

Expected Result: Browser should close.

Actual Result: Firefox crashed.

Getting Error: "Plugin container for FireFox has stopped working."

Any suggestions...

Victor Moraes
  • 964
  • 1
  • 11
  • 28
Grs007
  • 129
  • 1
  • 1
  • 7
  • Is there already an answer to this problem? Version 52.0.2 and driver.close() closes the geckodriver without a problem, but driver.quit() closes the Firefox with the Error you mentioned – Dominik Lemberger Apr 12 '17 at 10:31

10 Answers10

4

Workaround until we have concrete fix for this. Although several posts suggest this has been fixed in version 50 and above, the fact is this is not working consistently. I have installed latest version 54 on two machines of Windows 7 and driver. Quit is working fine on one and not on other with same Java and Selenium versions. As an alternative, for executing on Windows machines, the following code would help to kill all related processes of Firefox.

if (browser == "FIREFOX")) {
    try {
        Runtime.getRuntime().exec("taskkill /F /IM geckodriver.exe");
        Runtime.getRuntime().exec("taskkill /F /IM plugin-container.exe");
        Runtime.getRuntime().exec("taskkill /F /IM firefox.exe");
    } catch (IOException e) {
        e.printStackTrace();
    }
} else {
    driver.quit();
}
Antti29
  • 2,953
  • 12
  • 34
  • 36
SKSajjan
  • 101
  • 1
  • 2
3

driver.quit() did work for me

driver.close() did not.

Physically clicking on the close button using the mouse doesn't work.

Using Python 3.6, Selenium 3.4.3 together with geckodriver v.0.18.0 on Ubuntu 16.04.

n1k31t4
  • 2,745
  • 2
  • 24
  • 38
  • I can re-verify that this works on python 2.7 + ubuntu 16. note, if you call driver close before quit, this will not work. – FlyingZebra1 Jan 24 '18 at 19:31
2

Below solution is tested on Windows7 with Firefox49, Selenium 3.0.1, Python 3.5 and geckodriver-v0.11.1 and is working fine.

import os

Then call

os.system('tskill plugin-container')

before calling driver.quit()

Jose Cherian
  • 7,207
  • 3
  • 36
  • 39
1

You can't. This is a current bug which still is open. So on Windows OS, if one tries to kill the FireFox driver there is an errro: "Getting Error: "Plugin container for FireFox has stopped working."

I think this issue is open as of today: https://github.com/SeleniumHQ/selenium/issues/2701

This issue is not present on other OS and ChromeDriver cloese fine. It is just with FireFox and geckodriver.

Ali Rad
  • 159
  • 1
  • 6
  • 1
    This issue is now FIXED. If you use the latest version of FireFox, WebDriver and GeckoDriver....FireFox will shut down as expected. – Ali Rad May 26 '17 at 11:39
1

Go to \Program Files (x86)\Mozilla Firefox\

find plugin-container.exe

delete or rename it!

found solution here

Jlearner
  • 573
  • 4
  • 6
0

This is temporary workaround with sendkeys unicodes :

Actions builder = new Actions(driver);
builder.keyDown(Keys.ALT).sendKeys(String.valueOf('\u0066'));
builder.sendKeys(String.valueOf('\u0058'));
builder.perform();
nikhilp
  • 114
  • 3
0

Simple solution I tried for running tests on windows machine was to add this code before driver.quit() or driver.close() for firefox browser using geckodriver

try {
            Runtime.getRuntime().exec("taskkill /F /IM geckodriver.exe");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
SKSajjan
  • 101
  • 1
  • 2
0

I had a similar issue, the solutions was setting

"browser.tabs.remote.autostart.2" = false

in the browser profile preferences.

https://stackoverflow.com/a/45814451/2546759

Nir
  • 1,836
  • 23
  • 26
0

Has been fixed and worked for me with Firefox 76.0.1 (64-bit), geckodriver-v0.26.0-win64, Selenium 3.141.0, Python 3.8.

driver.close()

Closes the tab in focus

driver.quit()

Closes all windows and ends the webdriver session

JLange
  • 47
  • 1
  • 6
-2

Driver.close() should work without any issues.

We have an issue with driver.quit();

Check issue here - https://github.com/SeleniumHQ/selenium/issues/2701

Dev Raj
  • 650
  • 2
  • 7
  • 18
  • I just switched to gecko driver https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz and driver.close() does not work for me – Pavel Niedoba Oct 14 '16 at 14:58