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]: Dotnet Error in 4.11.0 when using ChromeDriverService.CreateDefaultService() #12483

Closed
timandella opened this issue Aug 3, 2023 · 11 comments

Comments

@timandella
Copy link

What happened?

When using ChromeDriverService.CreateDefaultService() to instantiate a ChromeDriver, the error "Unable to obtain chrome using Selenium Manager" occurs. This started happening in 4.11.0, but was fine in 4.10.0

How can we reproduce the issue?

var options = new ChromeOptions();
if (settings.Headless && !Debugger.IsAttached)
{
	options.AddArgument("--headless");
}
options.AddArgument("--window-size=1920,1080");
options.AddArgument("--enable-javascript");
options.AddArgument("--lang=en-GB");
options.AddUserProfilePreference("intl.accept_languages", "en-GB");

options.AddArgument("--ignore-certificate-errors");
options.AddArgument("--no-sandbox");
options.AddArgument("--disable-dev-shm-usage");
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Dismiss;


_context.Driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), options, TimeSpan.FromMinutes(2));

Relevant log output

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: /home/vsts/work/1/uecd-tests-e2e/net6.0/selenium-manager/linux/selenium-manager  --browser "chrome" --output json
  ----> System.ComponentModel.Win32Exception : An error occurred trying to start process '/home/vsts/work/1/uecd-tests-e2e/net6.0/selenium-manager/linux/selenium-manager' with working directory '/home/vsts/work/1/uecd-tests-e2e/net6.0'. Permission denied
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
  Stack Trace:
     at OpenQA.Selenium.DriverFinder.FullPath(DriverOptions options)
   at OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(ChromeOptions options)
   at OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService()
   at TestProject.Hooks.BeforeScenario.InitializeDriver(ChromeOptions options) in /home/vsts/work/1/s/apps/test/TestProject/TestProject/Hooks/BeforeScenario.cs:line 36
   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 TestProject.Features.AdminPageFeature.ScenarioCleanup()
   at TestProject.Features.AdminPageFeature.EmailFieldIsReadonlyByDefault() in /home/vsts/work/1/s/apps/test/TestProject/TestProject/Features/AdminPage.feature:line 47
--WebDriverException
   at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
   at OpenQA.Selenium.SeleniumManager.DriverPath(DriverOptions options)
   at OpenQA.Selenium.DriverFinder.FullPath(DriverOptions options)
--Win32Exception
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
--TearDown
   at TestProject.Hooks.Cleanup.TakeSceenShotOnError() in /home/vsts/work/1/s/apps/test/TestProject/TestProject/Hooks/Cleanup.cs:line 48
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)

Operating System

Linux

Selenium version

4.11.0

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

Chrome

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

ChromeDriver 114.0.5735.90

Are you using Selenium Grid?

N/A

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

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

@titusfortner
Copy link
Member

So permissions issues with .NET on Linux...

I don't see anything we've changed that should have affected the permissions between 4.10 and 4.11.
We've been working on some things, but none of them have been merged yet.

@nvborisenko do you think we should explicitly chmod the file for non-windows?

@nvborisenko
Copy link
Member

nvborisenko commented Aug 3, 2023

We have the same permissions for 4.10 and 4.11

nick@DESKTOP-SM1DOE9:~$ ls -l ~/.nuget/packages/selenium.webdriver/4.10.0/manager/linux
total 4408
-rwxr--r-- 1 nick nick 4512416 Jun  5 14:38 selenium-manager
nick@DESKTOP-SM1DOE9:~$ ls -l ~/.nuget/packages/selenium.webdriver/4.11.0/manager/linux
total 4896
-rwxr--r-- 1 nick nick 5009528 Jul 31 22:10 selenium-manager

@timandella can you please run it on your environment where the issue reproduces

ls -l /home/vsts/work/1/uecd-tests-e2e/net6.0/selenium-manager/linux/selenium-manager

@timandella
Copy link
Author

This is what the command returns...

-rw-r--r-- 1 vsts docker 4512416 Aug 3 16:34 /home/vsts/work/1/uecd-tests-e2e/net6.0/selenium-manager/linux/selenium-manager

@nvborisenko
Copy link
Member

So, this file is not executable. You lost file permission while were manipulating with it. Most likely it might be happened by archiving it, or downloading from external sources.

As a workaround you can set proper permission:

chmod +x /home/vsts/work/1/uecd-tests-e2e/net6.0/selenium-manager/linux/selenium-manager

But better if you find a stage in your process where you lose file attribute.

@timandella
Copy link
Author

The permissions listed above were obtained before our test application run, and is like that regardless of what version of Selenium are used (indeed I ran that command whilst running with 4.10.0 and there were no problems encountered).

@titusfortner
Copy link
Member

Oh. The difference in 4.11 is that Selenium manager is what is checking path instead of the bindings.

So I'm guessing you have the driver in path and selenium skipped the manager entirely in 4.10. Can you run the Selenium code with greater permissions?

@titusfortner
Copy link
Member

You can also create a service class instance with the location of the driver specified and this should also skip the manager.

@timandella
Copy link
Author

I tried the work around to use chmod to set permissions, and this was successful.

@titusfortner
Copy link
Member

There isn't anything obvious for Selenium to do. We probably can add a conditional to add an argument for Linux/Mac to explicitly chmod the file we're executing in the start process info, but I don't think we want to do that unless we see it as a bigger problem. I'm closing this for now.

Copy link

github-actions bot commented Dec 9, 2023

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

@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
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

3 participants