Open kevinoid opened 1 week ago
@kevinoid, thank you for creating this issue. We will troubleshoot it as soon as we can.
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!
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?
How I am reading it:
var driverService = ChromeDriverService.CreateDefaultService(); // just new driverService object
var driver1 = new ChromeDriver(driverService);
driver1.Dispose(); // you dispose driver1 but not driverService
var driver2 = new ChromeDriver(driverService);
driver2.Dispose(); // you dispose driver2 but not driverService
So, driverService
should not be disposed! And it is correct behavior.
So,
driverService
should not be disposed! And it is correct behavior.
Are you saying it is a bug that driverService
is disposed by driver1.Dispose()
? For reference, this occurs in WebDriver.Dispose()
, which calls DriverServiceCommandExecutor.Dispose()
: https://github.com/SeleniumHQ/selenium/blob/d922168d801e5a468ae3edbc68cb1055f04c9f41/dotnet/src/webdriver/WebDriver.cs#L731 which calls DriverService.Dispose()
: https://github.com/SeleniumHQ/selenium/blob/d922168d801e5a468ae3edbc68cb1055f04c9f41/dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs#L156
How it works currently:
var driverService = ChromeDriverService.CreateDefaultService();
var driver1 = new ChromeDriver(driverService); // starts new chromedriver.exe
driver1.Dispose(); // ends the chromedriver.exe
var driver2 = new ChromeDriver(driverService); // starts new chromedriver.exe
driver2.Dispose(); // DOES NOT end the chromedriver.exe
This is definitely a bug, user experience should be improved here. I don't know whether ChromeDriverService is supposed to be reusable: understanding it let's us understand what is expected user experience should be.
@diemol @titusfortner do you know whether ChromeDriverService
is considered as reusable object, comparing with other bindings?
@kevinoid did it work properly with previous Selenium version, and which one?
did it work properly with previous Selenium version, and which one?
@nvborisenko Testing just now, I'm able to reproduce the issue with Selenium.WebDriver versions back to 3.11.1, but I'm unable to reproduce the issue with 3.11.0 or earlier.
Thank you good man, it will help so much!
Current understanding is: ChromeDriverService should be reusable.
What happened?
Using the same instance of
ChromeDriverService
to construct a secondChromeDriver
instance after a first has been disposed causes achromedriver.exe
process to remain running after the program exits. The same issue occurs forEdgeDriverService
/EdgeDriver
(and presumably others, although I haven't tested).How can we reproduce the issue?
### Relevant log output
```shell 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: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