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]: Selenium 4.15 with C# - Exception in Parallel Test Execution "OpenQA.Selenium.NoSuchDriverException : Unable to obtain chrome using Selenium Manager" #13342

Closed
dcdraper opened this issue Dec 20, 2023 · 14 comments

Comments

@dcdraper
Copy link

What happened?

The failures are intermittent and do not happen in each run.

The tests fail with selenium-manager.exe exception "Unable to obtain chrome using Selenium Manager" and error message "The process cannot access the file because it is being used by another process. (os error 32)"

We are using a .runsettings file and setting NumberOfTestWorkers to 8. Only about three tests fail at the beginning of each run. It seems that once chrome is installed by one of the early tests/threads that the issue no longer presents.

Version 4.15 is the first and only version we have tried using to manage chrome and chromedriver.

As a workaround we are running the command "selenium-manager.exe --browser chrome --debug" on the test agent in the pipeline after building the solution and before the tests start running.

How can we reproduce the issue?

.runsettings file:
<?xml version="1.0" encoding="utf-8" ?> <RunSettings> <!-- Parameters used by tests at run time --> <TestRunParameters> <Parameter name="environment" value="DEV" /> <Parameter name="browser" value="CH_HEADLESS_MODE" /> <Parameter name="gridExecution" value="false" /> <Parameter name="includeScreenshotsInReport" value="true" /> <Parameter name="generateFileWithFailedTests" value="true" /> <Parameter name="loglevel" value="INFO" /> </TestRunParameters> <NUnit> <NumberOfTestWorkers>8</NumberOfTestWorkers> </NUnit> </RunSettings>

Relevant log output

From the execution log:
OpenQA.Selenium.NoSuchDriverException : Unable to obtain chrome using Selenium Manager; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
----> OpenQA.Selenium.WebDriverException : Error starting process: C:\a\1\s\SanityTestPack\bin\Debug\net7.0\selenium-manager\windows\selenium-manager.exe --browser "chrome" --output json
----> OpenQA.Selenium.WebDriverException : Selenium Manager process exited abnormally with 65 code: C:\a\1\s\SanityTestPack\bin\Debug\net7.0\selenium-manager\windows\selenium-manager.exe --browser "chrome" --output json
Standard Output >>
{
"logs": [
{
"level": "ERROR",
"timestamp": 1702678423,
"message": "The process cannot access the file because it is being used by another process. (os error 32)"
}
],
"result": {
"code": 65,
"message": "The process cannot access the file because it is being used by another process. (os error 32)",
"driver_path": "",
"browser_path": ""
}
}

<<

Stack trace
at OpenQA.Selenium.DriverFinder.FullPath(DriverOptions options)
at OpenQA.Selenium.Chromium.ChromiumDriver.GenerateDriverServiceCommandExecutor(DriverService service, DriverOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
[at SanityTestPack.TestBase.Base.StartWebBrowser() in C:\a\1\s\SanityTestPack\TestBase\Base.cs:line 278](https://dev.azure.com/GoEkos/Test%20Automation%20Framework/_git/05457c59-b0fd-421c-8963-dc5e0e85d9cf?path=%2fSanityTestPack%2fTestBase%2fBase.cs&version=GBworkitem%2f9791%2fuse-selenium-manager&_a=contents&line=278&lineEnd=279&lineStartColumn=1&lineEndColumn=1&lineStyle=plain)
[at SanityTestPack.TestBase.Base.InitializeBrowser(String url, String browser) in C:\a\1\s\SanityTestPack\TestBase\Base.cs:line 114](https://dev.azure.com/GoEkos/Test%20Automation%20Framework/_git/05457c59-b0fd-421c-8963-dc5e0e85d9cf?path=%2fSanityTestPack%2fTestBase%2fBase.cs&version=GBworkitem%2f9791%2fuse-selenium-manager&_a=contents&line=114&lineEnd=115&lineStartColumn=1&lineEndColumn=1&lineStyle=plain)
[at SanityTestPack.TestBase.Base.BeforeTestScenario() in C:\a\1\s\SanityTestPack\TestBase\Base.cs:line 41](https://dev.azure.com/GoEkos/Test%20Automation%20Framework/_git/05457c59-b0fd-421c-8963-dc5e0e85d9cf?path=%2fSanityTestPack%2fTestBase%2fBase.cs&version=GBworkitem%2f9791%2fuse-selenium-manager&_a=contents&line=41&lineEnd=42&lineStartColumn=1&lineEndColumn=1&lineStyle=plain)
at InvokeStub_Action`1.Invoke(Object, Object, IntPtr*)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioStart()
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()
at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()
at SanityTestPack.Specs.ActivityTypeFeature.ScenarioCleanup()
[at SanityTestPack.Specs.ActivityTypeFeature.Activity_Type_Create_Edit_Delete() in C:\a\1\s\SanityTestPack\Specs\ActivityType.feature:line 21](https://dev.azure.com/GoEkos/Test%20Automation%20Framework/_git/05457c59-b0fd-421c-8963-dc5e0e85d9cf?path=%2fSanityTestPack%2fSpecs%2fActivityType.feature&version=GBworkitem%2f9791%2fuse-selenium-manager&_a=contents&line=21&lineEnd=22&lineStartColumn=1&lineEndColumn=1&lineStyle=plain)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--WebDriverException
at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
at OpenQA.Selenium.SeleniumManager.DriverPath(DriverOptions options)
at OpenQA.Selenium.DriverFinder.FullPath(DriverOptions options)
--WebDriverException
at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)

Operating System

Windows 10

Selenium version

Selenium 4.15, C#

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

Chrome Version 120.0.6099.109 (Official Build) (64-bit)

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

chromedriver.exe x64 version 120.0.6099.71

Are you using Selenium Grid?

no

Copy link

@dcdraper, 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!

@diemol
Copy link
Member

diemol commented Dec 21, 2023

4.16.0 is out since a couple of weeks.

Can you please check that version?

@dcdraper
Copy link
Author

@diemol I cannot use 4.16.x due to issue #13261 which is not fixed until version 4.17. Do you know when to expect that version to be available?

@titusfortner
Copy link
Member

titusfortner commented Dec 28, 2023

We're trying to release when Google releases chrome, so we're shooting for - https://chromiumdash.appspot.com/schedule

You can try to use nightly, the last built should work... Hmm, looks like I messed up the nightly build with one of the recent changes, though, I guess I need to figure that out.

@titusfortner
Copy link
Member

And I just noticed this is C# not Java, so no nightly. Also, I think this may be related to #12425 ?

@tripplite
Copy link

You aren't alone. We started experiencing similar, if not the same issue as of stable version 4.16.1. We tried 4.16.2 as well and the issue is not resolved. We rolled back to 4.15.0 and all is well. Essentially, we have a .NET project (C#) which runs tests via Azure DevOps CI/CD in parallel across multiple agents. Have been using Selenium for some time and this is seemingly our first trouble.

4.15.0 - Example of log output from initial SmokeTest run via DevOps agent:

2024-01-02T02:30:14.9827820Z [RunStatistics]This execution slice with id '23460', received '8' testcases to execute out of which '8' is discovered.
2024-01-02T02:30:14.9828217Z [RunStatistics] Could not find a base definition run to get a history of execution times.
2024-01-02T02:30:14.9828491Z [RunStatistics] Anticipated execution time of current slice is unknown. This might be because the test cases are either new or failed in the previous run.
2024-01-02T02:30:14.9961219Z **************** Starting test execution *********************
2024-01-02T02:30:15.0058128Z Using new test platform for test execution
2024-01-02T02:30:15.0058685Z Microsoft.TestPlatform.VsTestConsole.TranslationLayer.VsTestConsoleWrapper instance will be created
2024-01-02T02:30:20.0722639Z RunMessage : SpecFlow+Runner execution started
2024-01-02T02:30:20.0741232Z RunMessage : SpecFlow+Runner 3.9.31 in Framework clr40 in x64 mode execution started
2024-01-02T02:30:20.0741965Z RunMessage : TestAdapter Location: C:\a\r1\a\_e2e\tests\Testing.UI\TechTalk.SpecRun.VisualStudio.TestAdapter.dll
2024-01-02T02:30:20.0742731Z RunMessage : Current UserName: 'XXXXX', MachineName: 'vmssda60900038H'
2024-01-02T02:30:20.2406556Z RunMessage : SpecRun: running tests in C:\a\r1\a\_e2e\tests\Testing.UI\Testing.UI.dll
2024-01-02T02:30:20.2408082Z RunMessage : Output folder configured to "C:\a\_temp\TestResults" (default)
2024-01-02T02:30:20.2408289Z RunMessage : Profile: Testing.UI
2024-01-02T02:30:20.3063303Z RunMessage : Log file path: C:\a\_temp\TestResults\Testing.UI.Testing.UI_2024-01-01T203020.log
2024-01-02T02:30:20.3137471Z RunMessage : Checking activation
2024-01-02T02:30:20.3325502Z RunMessage : Activation check completed
2024-01-02T02:30:20.3326143Z RunMessage : Starting test run
2024-01-02T02:30:20.3982099Z RunMessage : Discovering target: Default
2024-01-02T02:30:20.3982748Z RunMessage : Discovering tests from assembly: C:\a\r1\a\_e2e\tests\Testing.UI\Testing.UI.dll
2024-01-02T02:30:21.7768803Z RunMessage : Discovered tests from assembly: C:\a\r1\a\_e2e\tests\Testing.UI\Testing.UI.dll
2024-01-02T02:37:22.6381198Z RunMessage : Scenario: Pages load with the UI flags turned on, Variant 23 in Smoke Test -> Succeeded on thread #5
2024-01-02T02:37:24.0175433Z Passed    Testing.UI.Smoke Test.#()::TestAssembly:Testing.UI/Feature:Smoke+Test/Scenario:Pages+load+with+the+UI+flags+turned+on%2c+Variant+23    Pages load with the UI flags turned on, Variant 23

4.16.2 - Example of log output from initial SmokeTest run via DevOps agent - immediate failures, no tests run:

2024-01-04T17:43:23.0690164Z [RunStatistics]This execution slice with id '23536', received '8' testcases to execute out of which '8' is discovered.
2024-01-04T17:43:23.0690439Z [RunStatistics] Could not find a base definition run to get a history of execution times.
2024-01-04T17:43:23.0690787Z [RunStatistics] Anticipated execution time of current slice is unknown. This might be because the test cases are either new or failed in the previous run.
2024-01-04T17:43:23.0804722Z **************** Starting test execution *********************
2024-01-04T17:43:23.0889514Z Using new test platform for test execution
2024-01-04T17:43:23.0890120Z Microsoft.TestPlatform.VsTestConsole.TranslationLayer.VsTestConsoleWrapper instance will be created
2024-01-04T17:43:27.4242151Z RunMessage : SpecFlow+Runner execution started
2024-01-04T17:43:27.4258101Z RunMessage : SpecFlow+Runner 3.9.31 in Framework clr40 in x64 mode execution started
2024-01-04T17:43:27.4260765Z RunMessage : TestAdapter Location: C:\a\r1\a\_e2e\tests\Testing.UI\TechTalk.SpecRun.VisualStudio.TestAdapter.dll
2024-01-04T17:43:27.4261472Z RunMessage : Current UserName: 'XXXXX', MachineName: 'vmssda609000394'
2024-01-04T17:43:27.5683968Z RunMessage : SpecRun: running tests in C:\a\r1\a\_e2e\tests\Testing.UI\Testing.UI.dll
2024-01-04T17:43:27.5685434Z RunMessage : Output folder configured to "C:\a\_temp\TestResults" (default)
2024-01-04T17:43:27.5685627Z RunMessage : Profile: Testing.UI
2024-01-04T17:43:27.6162223Z RunMessage : Log file path: C:\a\_temp\TestResults\Testing.UI_Testing.UI_2024-01-04T114327.log
2024-01-04T17:43:27.6230704Z RunMessage : Checking activation
2024-01-04T17:43:27.6358497Z RunMessage : Activation check completed
2024-01-04T17:43:27.6358711Z RunMessage : Starting test run
2024-01-04T17:43:27.6889848Z RunMessage : Discovering target: Default
2024-01-04T17:43:27.6890695Z RunMessage : Discovering tests from assembly: C:\a\r1\a\_e2e\tests\Testing.UI\Testing.UI.dll
2024-01-04T17:43:28.9570653Z RunMessage : Discovered tests from assembly: C:\a\r1\a\_e2e\tests\Testing.UI\Testing.UI.dll
2024-01-04T17:43:38.7291400Z RunMessage : Scenario: Pages load with the new UI flags turned on, Variant 15 in Smoke Test -> Failed on thread #2
2024-01-04T17:43:38.7296954Z ##[error]RunMessage : 	[ERROR] Unable to obtain chrome using Selenium Manager; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location -> Error starting process: C:\a\r1\a\_e2e\tests\Testing.UI\selenium-manager\windows\selenium-manager.exe  --browser "chrome" --output json -> Selenium Manager process exited abnormally with -1073741515 code: C:\a\r1\a\_e2e\tests\Testing.UI\selenium-manager\windows\selenium-manager.exe  --browser "chrome" --output json

We might try and see if the workaround mentioned "selenium-manager.exe --browser chrome --debug" will work for us but we will likely stay on 4.15.0 for the time being.

@tripplite
Copy link

Heads up - we have upgraded and tested 4.17.0 version and thus far, it appears to be working.

@titusfortner
Copy link
Member

Excellent. I'll close this, then. We can re-open if we determine this bug is still present

@dcdraper
Copy link
Author

dcdraper commented Jan 26, 2024

@titusfortner
We are still seeing the errors with Selenium 4.17. We run 8 in parallel but on one agent, not across agents like @tripplite.
The workaround to run "selenium-manager.exe --debug --browser chrome" before the tests start still seems to work for us.

Error Message:
   OpenQA.Selenium.NoSuchDriverException : Unable to obtain chrome using Selenium Manager; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
  ----> OpenQA.Selenium.WebDriverException : Error starting process: C:\a\1\s\SanityTestPack\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe  --browser "chrome" --language-binding csharp --output json
  ----> OpenQA.Selenium.WebDriverException : Selenium Manager process exited abnormally with 65 code: C:\a\1\s\SanityTestPack\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe  --browser "chrome" --language-binding csharp --output json
Standard Output >>
{
  "logs": [
    {
      "level": "ERROR",
      "timestamp": 1706294296,
      "message": "The process cannot access the file because it is being used by another process. (os error 32)"
    }
  ],
  "result": {
    "code": 65,
    "message": "The process cannot access the file because it is being used by another process. (os error 32)",
    "driver_path": "",
    "browser_path": ""
  }
}

<<

  Stack Trace:
     at OpenQA.Selenium.DriverFinder.FullPath(DriverOptions options)
   at OpenQA.Selenium.Chromium.ChromiumDriver.GenerateDriverServiceCommandExecutor(DriverService service, DriverOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
   at SanityTestPack.TestBase.Base.StartWebBrowser() in C:\a\1\s\SanityTestPack\TestBase\Base.cs:line 273
   at SanityTestPack.TestBase.Base.InitializeBrowser(String url, String browser) in C:\a\1\s\SanityTestPack\TestBase\Base.cs:line 109
   at SanityTestPack.TestBase.Base.BeforeTestScenario() in C:\a\1\s\SanityTestPack\TestBase\Base.cs:line 36
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioStart()

@titusfortner titusfortner reopened this Jan 26, 2024
@titusfortner
Copy link
Member

We have several similar issues open in multiple languages. We should review our overall strategy.

@titusfortner
Copy link
Member

I think these have been addressed. I'm closing this.

@titusfortner titusfortner closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2024
@dcdraper
Copy link
Author

dcdraper commented Mar 8, 2024

@titusfortner which version addresses this?

@dcdraper
Copy link
Author

dcdraper commented Mar 13, 2024

I updated to 4.18.1 and I am still seeing errors:

INFO Bold: Ending test..

ERROR: OpenQA.Selenium.NoSuchDriverException : Unable to obtain chrome using Selenium Manager; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
----> OpenQA.Selenium.WebDriverException : Error starting process: C:\a\1\s\SanityTestPack\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe --browser "chrome" --language-binding csharp --output json
----> OpenQA.Selenium.WebDriverException : Selenium Manager process exited abnormally with 65 code: C:\a\1\s\SanityTestPack\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe --browser "chrome" --language-binding csharp --output json
Standard Output >>
{
"logs": [
{
"level": "ERROR",
"timestamp": 1710362531,
"message": "The process cannot access the file because it is being used by another process. (os error 32)"
}
],
"result": {
"code": 65,
"message": "The process cannot access the file because it is being used by another process. (os error 32)",
"driver_path": "",
"browser_path": ""
}
}

Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants