selenium: ChromeWebDriver.dispose() does not execute HTTP command after timeout

Meta -

OS: Windows 10

Selenium Version:
“Selenium.WebDriver” version=“3.8.0” “Selenium.WebDriver.ChromeDriver” version=“2.34.0”

Browser:
Chrome

Browser Version:
Versjon 64.0.3282.167 (64-bit)

Expected Behavior -

driver.Dispose(); - close open drivers and clean up their processes. This works if no timeout occurs.

Actual Behavior -

chromedriver.exe is registered as an app in Task manager, with two “children”: image

When driver.dispose() is called after a timeout in the browser, the HTTP command directed to the webdriver is not executed.

“OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:port/session/sessionid/element timed out after 60 seconds. ----> System.Net.WebException : The request was aborted: The operation has timed out.”

Only the “chromedriver.exe” app and processchild is killed, leaving the Console window Host an orphan process. However, this orphaned process is holding the chromedriver.exe process, so the next time we run our tests the build folder cannot be cleaned.

Steps to reproduce -

The ReproduceError() test, will as the name says, reproduce the error as long as a breakpoint in fiddler are set: bpu https://google.com and one waits for selenium to timeout. The windows will not close, in the cleanup.

We have a temporary worakaround demonstrated in ErrorWorkAround(), using processid’s to kill the process in question (still using a breakpoint in fiddler, and waiting for the timeout to appear).

    [Test]
    public void ReproduceError()
    {
        using (var driver = new ChromeDriver())
        {
            try
            {
                driver.Navigate().GoToUrl("https://bing.com");
                // Set breakpoint in fiddler: bpu https://google.com
                // Wait for selenium to timeout
                driver.Navigate().GoToUrl("https://google.com");
                driver.FindElementById("fkbx-text");
            }
            finally
            {
                driver.Dispose();
            }
        }
    }

    [Test]
    public void ErrorWorkAround()
    {
        var service = ChromeDriverService.CreateDefaultService();
        ChromeDriver driver;
        try
        {
            driver = new ChromeDriver(service);
            
            driver.Navigate().GoToUrl("https://bing.com");
            // Set breakpoint in fiddler: bpu https://google.com
            // Wait for selenium to timeout
            driver.Navigate().GoToUrl("https://google.com");
            driver.FindElementById("fkbx-text");
        }
        finally
        {
            var pid = service.ProcessId;
            Process.GetProcessById(pid).CloseMainWindow();
        }
    }

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 16 (4 by maintainers)

Most upvoted comments

I think something like this could be added to the dispose in DriverServiceCommandExecutor in order to always clean up the child processes.

It would be better to fix the actual issue than applying a workaround for cleaning up orphaned drivers.