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]: OpenQA.Selenium.NoSuchDriverException #12675

Closed
ralfbalzer opened this issue Sep 3, 2023 · 31 comments
Closed

[🐛 Bug]: OpenQA.Selenium.NoSuchDriverException #12675

ralfbalzer opened this issue Sep 3, 2023 · 31 comments

Comments

@ralfbalzer
Copy link

What happened?

I have updated vom Verison 4.11 to 4.12 (also tried the latest 4.12.2 version) and since the update, I am getting the following error message:

`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:\inetpub\wwwroot\Gruppenhaus.Web\selenium-manager/windows/selenium-manager.exe --browser "chrome" --output json
---> OpenQA.Selenium.WebDriverException: Selenium Manager process exited abnormally with -1073740791 code: C:\inetpub\wwwroot\Gruppenhaus.Web\selenium-manager/windows/selenium-manager.exe --browser "chrome" --output json

at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
--- End of inner exception stack trace ---
at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
at OpenQA.Selenium.SeleniumManager.DriverPath(DriverOptions options)
at OpenQA.Selenium.DriverFinder.FullPath(DriverOptions options)
--- End of inner exception 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(ChromeDriverService service, ChromeOptions options)
`
Works finde in 4.11

How can we reproduce the issue?

ChromeOptions _chromeOptions = new();
         _chromeOptions.AddArgument("--headless");
         IWebDriver driver = new ChromeDriver(_chromeOptions);

Relevant log output

No logfile as in NetCore

Operating System

Windows Server

Selenium version

4.12

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?

should be determined by the download. 4.11 auto downloads 116.0.5845.96

Are you using Selenium Grid?

No response

@github-actions
Copy link

github-actions bot commented Sep 3, 2023

@ralfbalzer, 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

There's an error starting this process. I'm assuming it doesn't like the mixing of the forward and back slashes?

C:\inetpub\wwwroot\Gruppenhaus.Web\selenium-manager/windows/selenium-manager.exe

AppContext.BaseDirectory is resolving as C:\inetpub\wwwroot\Gruppenhaus.Web\.
https://github.com/SeleniumHQ/selenium/blob/selenium-4.12.0/dotnet/src/webdriver/SeleniumManager.cs#L41

What framework are you targeting? The only change I see in 4.12 is that we used to use Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); for NET45 which we no longer support.

@nvborisenko any ideas what would have changed?

@ralfbalzer
Copy link
Author

@titusfortner I am using net7.0. It#s an MVC application.

@nvborisenko
Copy link
Member

@ralfbalzer could you please run it manually in console?

C:\inetpub\wwwroot\Gruppenhaus.Web\selenium-manager/windows/selenium-manager.exe --browser "chrome" --output json

@ralfbalzer
Copy link
Author

That works fine. Gives me the json output.

@nvborisenko
Copy link
Member

@ralfbalzer please help us one more time:

C:\inetpub\wwwroot\Gruppenhaus.Web\selenium-manager/windows/selenium-manager.exe --browser "chrome" --output json
echo %errorlevel%

And share entire output, thx.

@nvborisenko
Copy link
Member

I believe it works as expected, and exit code is 0.

Action items for C# binding: we need listen to error output stream from Selenium Manager and include it in raised exception. It will allow us to see what exactly was wrong with Selenium Manager. I think this issue is related to permissions, like Selenium Manager wants to write to tmp directory, but has no enough permission because the process is hosted under IIS.

So, Ralf, please wait next release (or patch?), it will reveal original issue.

@nvborisenko
Copy link
Member

@ralfbalzer please try 4.12.4 and share the exception.

@ralfbalzer
Copy link
Author

@nvborisenko I did and it is still throwing the same error.
The Exception has now the following additional info:
Error Output >> thread 'main' panicked at 'called Result::unwrap()on anErrvalue: Os { code: 3, kind: NotFound, message: "Das System kann den angegebenen Pfad nicht finden." }', src\lib.rs:873:14 note: run withRUST_BACKTRACE=1 environment variable to display a backtrace
"Das System kann den angegebenen Pfad nicht finden" means "The system could not find the specified path" - ;-)

@nvborisenko
Copy link
Member

@bonigarcia it's for you

The system could not find the specified path
src\lib.rs:873:14

@bonigarcia
Copy link
Member

I'm confused about this issue since the Selenium Manager binaries remain the same across all Selenium 4.12.*, and it seems it was working fine (since the JSON output was displayed). But then, a panic error happens (and in that case, the JSON cannot be produced).

@ralfbalzer: To try to trace this problem, can you please do the following?

  1. Download the current Selenium Manager binary for Windows from here. This is the one shipped with Selenium 4.12.*.
  2. With that binary, run this command using the shell:
selenium-manager --browser chrome --debug
  1. Share the output here.

Also, I have prepared a new Selenium Manager binary, trying to improve the line src\lib.rs:873:14. Please repeat the process before, but this time, using this new binary. Thanks.

@ralfbalzer
Copy link
Author

@bonigarcia the output is identical in both versions:
DEBUG chromedriver not found in PATH DEBUG chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe DEBUG Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value DEBUG Output: "\r\r\n\r\r\nVersion=116.0.5845.142\r\r\n\r\r\n\r\r\n\r" DEBUG Detected browser: chrome 116.0.5845.142 DEBUG Required driver: chromedriver 116.0.5845.96 DEBUG chromedriver 116.0.5845.96 already in the cache INFO Driver path: C:\Users\ralfb\.cache\selenium\chromedriver\win64\116.0.5845.96\chromedriver.exe INFO Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

@bonigarcia
Copy link
Member

Thanks. That seems to indicate that Selenium Manager is working properly.

@nvborisenko
Copy link
Member

The difference is that Selenium Manager is ran under IIS (web hosting process). Potential issue is that rust cannot determine C:\Users\ralfb\.cache.

@ralfbalzer
Copy link
Author

ralfbalzer commented Sep 6, 2023

@nvborisenko Just some additional information. As I mentioned, if i go back to 4.11 this all works fine.
It also works fine in my Dev environemnt, even on the latest version.

When I publish the app to my local IIS, it creates the "selenium-manager" folder as part of the publish command.
Once I run the code that uses Selenium on the IIS version, it creates the folder "chromedriver" with the windows version of the chromedriver.exe.

However, in version 4.11 - on the live server, it also creates a folder called "chrome"
Screenshot 2023-09-06 191818

In version 4.12, it does not create this folder. Maybe this helps?

@nvborisenko
Copy link
Member

Interesting, I don't see chromedriver.exe file. @ralfbalzer could you please compare the content of folders, you mentioned, with 4.11 and 4.12?

@ralfbalzer
Copy link
Author

@nvborisenko Sorry - I confused things here, as I keep switching between versions. In 4.12, none of the folders get created.

@ralfbalzer
Copy link
Author

@nvborisenko I just noticed sonething else. In the nuget Packages folder, I see the following:
nuget

The package for 4.12, only has a lib folder for netstandard 2.0.
The WebDriver.dll distributed with verison 4.12 is only 4.34MB, whilst the one I have on the live server at the moment is 6.17MB. Could the problem be the WebDriver.dll?

@nvborisenko
Copy link
Member

No, the problem is definitely somewhere in selenium-manager.exe process.

@bonigarcia
Copy link
Member

I am lost with this issue, but if it is caused by the problem reported here, it might be fixed with the change I made to Selenium Manager.

I'm unfamiliar with .Net, but I believe we can make changes directly on the distribution. Is that right? I mean, substitute the file 4.12.4\manager\windows\selenium-manager.exe with the binary downloaded (and decompressed) from here.

@ralfbalzer If possible, can you do that (in the environment in which the error happens)? And then, repeat the test which is failing.

@ralfbalzer
Copy link
Author

ralfbalzer commented Sep 7, 2023

@bonigarcia That actually worked. I copied the downloaed file into the \selenium-manager\windows folder, ran the code and it worked fine.

@bonigarcia
Copy link
Member

Great, thanks for checking. I have just sent a PR to fix it.

@mortizacc
Copy link

Which version will the above PR be implemented in? I'm having the same issue as OP

@titusfortner
Copy link
Member

4.13

@nuthanbanad
Copy link

nuthanbanad commented Sep 12, 2023

@bonigarcia
I used the selenium-manager.exe provided by you and still get below error after running for a day.
This starts happening after a day on my remote PC where my console application is executed as scheduled task everyday.

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:\DM_FOTA_Download_Service\Latest\selenium-manager/windows/selenium-manager.exe --browser "chrome" --output json ---> OpenQA.Selenium.WebDriverException: Selenium Manager process exited abnormally with 65 code: C:\DM_FOTA_Download_Service\Latest\selenium-manager/windows/selenium-manager.exe --browser "chrome" --output json
Error Output >>

Standard Output >>
{
"logs": [
{
"level": "ERROR",
"timestamp": 1694550606,
"message": "expected value at line 1 column 1"
}
],
"result": {
"code": 65,
"message": "expected value at line 1 column 1",
"driver_path": "",
"browser_path": ""
}
}

at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
--- End of inner exception stack trace ---
at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
at OpenQA.Selenium.SeleniumManager.DriverPath(DriverOptions options)
at OpenQA.Selenium.DriverFinder.FullPath(DriverOptions options)
--- End of inner exception 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 DonwloadGroupDeviceListData.Form1.createSeleniumChromeBrowser()
at DonwloadGroupDeviceListData.Form1.<Form1_Shown>d__25.MoveNext()
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 DonwloadGroupDeviceListData.Form1.createSeleniumChromeBrowser()
at DonwloadGroupDeviceListData.Form1.<Form1_Shown>d__25.MoveNext()

@bonigarcia
Copy link
Member

@nuthanbanad I don't have any context of your problem. In any case, you can try the following to get more info about it:

selenium-manager.exe --browser chrome --trace

@nvborisenko
Copy link
Member

@bonigarcia I think author sometimes faces the issue, that SM expects something in one format, but gets it in some another. Most likely SM did http request to get a list of available web drivers (json format), but this request may fail, we see expected value at line 1 column 1 error.

If it's true, SM can just verify http response code to be 200, and fails in others cases, including http response body in error message (stacktrace).

@bonigarcia
Copy link
Member

@nvborisenko Indeed, the error expected value at line 1 column 1 can be confusing. It is thrown by the crate serde_json when the expected JSON response is not received (e.g. due a connectivity issue).

When PR #12852 is merged, Selenium Manager will use a crate called anyhow that will allow to include some context on errors. I will try to add some extra information when that error happens to clarify the cause.

@nvborisenko
Copy link
Member

Thank @bonigarcia. I am closing this issue (for 4.12). If everybody else sees issues like "Unable to obtain chrome using Selenium Manager", please post new issue. At least selenium 4.15 will show why Selenium Manager couldn't obtain Chrome, then it would be easier to land quick fix. Thanks.

@bonigarcia
Copy link
Member

I created PR #13291 for SM to throw a more descriptive message when JSON parsing errors from responses.

Copy link

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 Jan 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

7 participants