Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: C#: Driver process left running if DriverService is reused and Driver disposed #14624

Open
kevinoid opened this issue Oct 19, 2024 · 2 comments

Comments

@kevinoid
Copy link

kevinoid commented Oct 19, 2024

What happened?

Using the same instance of ChromeDriverService to construct a second ChromeDriver instance after a first has been disposed causes a chromedriver.exe process to remain running after the program exits. The same issue occurs for EdgeDriverService/EdgeDriver (and presumably others, although I haven't tested).

How can we reproduce the issue?

var driverService = ChromeDriverService.CreateDefaultService();
var driver1 = new ChromeDriver(driverService);
driver1.Dispose();
var driver2 = new ChromeDriver(driverService);
driver2.Dispose();

Relevant log output

18:12:02.680 TRACE SeleniumManager: Driver path: C:\Users\Kevin\.cache\selenium\chromedriver\win64\130.0.6723.58\chromedriver.exe
18:12:02.684 TRACE SeleniumManager: Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe
Starting ChromeDriver 130.0.6723.58 (3a50e012e4c9b8a410a4e2b12bf577e69ee8f755-refs/branch-heads/6723@{#1353}) on port 56805
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully on port 56805.
18:12:03.024 DEBUG HttpCommandExecutor: Executing command: []: newSession {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"binary":"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"}}]}}
18:12:03.049 TRACE HttpCommandExecutor: >> Method: POST, RequestUri: 'http://localhost:56805/session', Version: 1.1, Content: System.Net.Http.ByteArrayContent, Headers:
{
  Accept: application/json; charset=utf-8
  User-Agent: selenium/4.25.0
  User-Agent: (.net windows)
  Content-Type: application/json; charset=utf-8
}
{"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"binary":"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"}}]}}

DevTools listening on ws://127.0.0.1:56808/devtools/browser/69268b21-d6f4-4d17-adc8-0bb82d03c81f
18:12:09.128 TRACE HttpCommandExecutor: << StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Cache-Control: no-cache
  Content-Length: 880
  Content-Type: application/json; charset=utf-8
}
18:12:09.229 DEBUG HttpCommandExecutor: Response: (18ded7c147cc833ccfa3021204277f05 Success: System.Collections.Generic.Dictionary`2[System.String,System.Object])
18:12:09.673 DEBUG HttpCommandExecutor: Executing command: [18ded7c147cc833ccfa3021204277f05]: quit {}
18:12:09.768 TRACE HttpCommandExecutor: >> Method: DELETE, RequestUri: 'http://localhost:56805/session/18ded7c147cc833ccfa3021204277f05', Version: 1.1, Content: <null>, Headers:
{
  User-Agent: selenium/4.25.0
  User-Agent: (.net windows)
  Accept: application/json
  Accept: image/png
}
18:12:12.719 TRACE HttpCommandExecutor: << StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Cache-Control: no-cache
  Content-Length: 14
  Content-Type: application/json; charset=utf-8
}
18:12:12.720 DEBUG HttpCommandExecutor: Response: ( Success: )
Starting ChromeDriver 130.0.6723.58 (3a50e012e4c9b8a410a4e2b12bf577e69ee8f755-refs/branch-heads/6723@{#1353}) on port 56805
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully on port 56805.
18:12:14.313 DEBUG HttpCommandExecutor: Executing command: []: newSession {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{}}]}}
18:12:14.322 TRACE HttpCommandExecutor: >> Method: POST, RequestUri: 'http://localhost:56805/session', Version: 1.1, Content: System.Net.Http.ByteArrayContent, Headers:
{
  Accept: application/json; charset=utf-8
  User-Agent: selenium/4.25.0
  User-Agent: (.net windows)
  Content-Type: application/json; charset=utf-8
}
{"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{}}]}}

DevTools listening on ws://127.0.0.1:56818/devtools/browser/c557c74a-4deb-4032-af34-de1cb7df9c9f
18:12:17.843 TRACE HttpCommandExecutor: << StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Cache-Control: no-cache
  Content-Length: 882
  Content-Type: application/json; charset=utf-8
}
18:12:17.864 DEBUG HttpCommandExecutor: Response: (fbc0e9deb4d2f1929299573b6f0c8826 Success: System.Collections.Generic.Dictionary`2[System.String,System.Object])
18:12:18.098 DEBUG HttpCommandExecutor: Executing command: [fbc0e9deb4d2f1929299573b6f0c8826]: quit {}
18:12:18.147 TRACE HttpCommandExecutor: >> Method: DELETE, RequestUri: 'http://localhost:56805/session/fbc0e9deb4d2f1929299573b6f0c8826', Version: 1.1, Content: <null>, Headers:
{
  User-Agent: selenium/4.25.0
  User-Agent: (.net windows)
  Accept: application/json
  Accept: image/png
}
18:12:21.467 TRACE HttpCommandExecutor: << StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Cache-Control: no-cache
  Content-Length: 14
  Content-Type: application/json; charset=utf-8
}
18:12:21.468 DEBUG HttpCommandExecutor: Response: ( Success: )

Operating System

Windows 10

Selenium version

C# with Selenium.WebDriver 4.25.0

What are the browser(s) and version(s) where you see this issue?

Chrome 130.0.6723.59

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 130.0.6723.58

Are you using Selenium Grid?

No

Copy link

@kevinoid, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@kevinoid
Copy link
Author

If it is incorrect to reuse an instance of DriverService, perhaps it would make sense for the Driver constructor to throw, or for DriverService to throw instead of starting a new driver service process from a disposed instance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant