Grs007
Grs007

Reputation: 129

How to close geckodriver with selenium 3.0.0 beta

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...

Upvotes: 8

Views: 15035

Answers (10)

JLange
JLange

Reputation: 47

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

Upvotes: 0

n1k31t4
n1k31t4

Reputation: 2874

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.

Upvotes: 3

Nir
Nir

Reputation: 2044

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

Upvotes: 0

SKSajjan
SKSajjan

Reputation: 101

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

Upvotes: 4

SKSajjan
SKSajjan

Reputation: 101

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

Upvotes: 0

Jlearner
Jlearner

Reputation: 613

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

find plugin-container.exe

delete or rename it!

found solution here

Upvotes: 1

Ali Rad
Ali Rad

Reputation: 159

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.

Upvotes: 1

Jose Cherian
Jose Cherian

Reputation: 7707

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

Upvotes: 2

Dev Raj
Dev Raj

Reputation: 660

Driver.close() should work without any issues.

We have an issue with driver.quit();

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

Upvotes: -2

nikhilp
nikhilp

Reputation: 114

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

Upvotes: 0

Related Questions