Chromedriver quit() method doesn't close all chrome.exe processes

See original GitHub issue

OS: Windows 7 (64-bit) Selenium Version: 3.14 Browser: Chrome, Firefox

Browser Version:
Google Chrome 68.0.3440.106 (Official Build) (64-bit)

Expected Behavior -

chromedriver.exe processes to be closed. geckodriver.exe processes to be closed.

Actual Behavior -

Hello guys, since a month ago, we’re expecting some kind of problems trying to kill the chromedriver.exe and geckodriver.exe processes.

We usually run several tests simultaneously and when the TestSuite ends, many chromedriver.exe / geckodriver.exe processes still there on the system.

This problem causes the system goes slower and slower, causing at the end the system crashes.

This is the message we’re receiving from the driver:

Trace init:

Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 36461
Only local connections are allowed.
ago 21, 2018 1:59:03 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

When we try to quit() the driver:

INFO: Unable to drain process streams. Ignoring but the exception being swallowed follows.
org.apache.commons.exec.ExecuteException: The stop timeout of 2000 ms was exceeded (Exit value: -559038737)
	at org.apache.commons.exec.PumpStreamHandler.stopThread(PumpStreamHandler.java:295)
	at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:181)
	at org.openqa.selenium.os.OsProcess.destroy(OsProcess.java:135)
	at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:153)
	at org.openqa.selenium.remote.service.DriverService.stop(DriverService.java:223)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:95)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
	at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:448)
	at utils.Utils.quit(Utils.java:2783)
	at utils.Utils.guardarResultado(Utils.java:2816)
	at com.bbva.ebcf.pon.LimitePonMismoUsuarioFirmando.tearDown(LimitePonMismoUsuarioFirmando.java:163)
	at junit.framework.TestCase.runBare(TestCase.java:140)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

ago 22, 2018 9:31:43 AM org.openqa.selenium.os.OsProcess destroy
SEVERE: Unable to kill process java.lang.ProcessImpl@70eecdc2

This is not happening every single time, for example, if we try to reproduce the error in oir IDE’s it is almost impossible. It seems that is something related whith too many chrome processes running at the same time (My guess).

This is the method we call in every single test we run (in @After ) we close and quit the driver:

	public static void quitDriver(WebDriver driver)
	{

		try
		{

			driver.close();
		}
		catch(Exception e1)
		{
			
		}

		try
		{
			driver.quit();
		}
		catch(Exception e)
		{

		}

	}

And this is the way we start the driver:

	System.setProperty("webdriver.chrome.driver", "lib/chromedriver.exe");

	String downloads = new File("downloads").getAbsolutePath();				
	HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
	chromePrefs.put("profile.default_content_settings.popups", 0);
	chromePrefs.put("download.default_directory", downloads);	
	chromePrefs.put("download.prompt_for_download", false);
	chromePrefs.put("download.directory_upgrade", true);

	ChromeOptions options = new ChromeOptions();
	options.setExperimentalOption("prefs", chromePrefs);
	options.addArguments("enable-automation");
	options.addArguments("start-maximized");
	options.addArguments("disable-popup-blocking");
	options.addArguments("disable-default-apps"); 
	//options.addArguments("--no-sandbox");
	options.addArguments("ignore-certificate-errors");
	
	LoggingPreferences logPrefs = new LoggingPreferences();
	logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
	
	options.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
	options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
	
	driver = new ChromeDriver(options);

We have tried almost everything (we are 5 testing engineers working on the same project) and the processes are still there.

image

Windows can’t kill the process with taskkill /f /im chromedriver.exe

image

So… Please, if someone have some idea, we would appreciate it. We have read a lot, before opening this issue.

Thank you guys! Thank you community!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:24 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
fenixadarcommented, Jan 24, 2019

https://stackoverflow.com/questions/10752512/get-pid-of-browser-launched-by-selenium/13650111 there is the answer. I have same issue, but i sloved. u can try"ChromeDriverService service = ChromeDriverService.createDefaultService();" before create ChromeDriver,u will find this issue is not exists

3reactions
spetrovascommented, Jan 2, 2019

In our code we always had “–no-sandbox” COMMENTED OUT and the problem is still there. I’m wondering why no one addresses this issue in the Selenium code; here is a scriplet from org.openqa.selenium.os.OsProcess class; have a look at the comment: `public int destroy() { SeleniumWatchDog watchdog = executeWatchdog; watchdog.waitForProcessStarted();

// I literally have no idea why we don't try and kill the process nicely on Windows. If you do,
// answers on the back of a postcard to SeleniumHQ, please.
if (!thisIsWindows()) {
  watchdog.destroyProcess();
  watchdog.waitForTerminationAfterDestroy(2, SECONDS);
}

if (isRunning()) {
  watchdog.destroyHarder();
  watchdog.waitForTerminationAfterDestroy(1, SECONDS);
}`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Chromedriver quit() method doesn't close all chrome.exe ...
Yeah, it can be a general issue as browsers (especially Chrome) don't always like closing their driver processes.
Read more >
Chromedriver quit() method doesn't close all chrome.exe ...
Issue Description: Chromedriver quit() method doesn't close all chrome.exe processes. Environment: java 1.8.0_45. OS Win 7 chrome driver v2.15
Read more >
release Selenium chromedriver.exe from memory
per the Selenium API, you really should call browser.quit() as this method will close all windows and kills the process. You should still...
Read more >
How do I kill the Chrome driver processor by using selenium
As per the Selenium API, you really should call browser.quit() as this method will close all windows and kills the process.
Read more >
How to kill the Chrome driver processor by using selenium
We can kill Chrome driver processor with many options. · : By Using Selenium webdriver · driver.close() : will close the existing chrome...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found