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]: Error occurs if path contains multibyte characters #14066

Closed
matsuda-dcom opened this issue Jun 3, 2024 · 16 comments
Closed

[🐛 Bug]: Error occurs if path contains multibyte characters #14066

matsuda-dcom opened this issue Jun 3, 2024 · 16 comments

Comments

@matsuda-dcom
Copy link

matsuda-dcom commented Jun 3, 2024

What happened?

I noticed one day that my Jenkins job was failing.
I am writing tests for a web application with selenium using C#.
new ChromeDriver() fails if the path of the project file being tested contains multi-byte characters.
As far as I remember, no errors occurred in ver4.10.0.
The test passes by removing multibyte characters from the path.

How can we reproduce the issue?

Write and execute test code in a file whose path contains multibyte characters.

ChromeOptions options = new ChromeOptions();
var driver = new ChromeDriver(service, options);

Relevant log output

OpenQA.Selenium.WebDriverException : Error starting process: C:\ProgramData\Jenkins\.jenkins\workspace\テスト\システムテスト\MyProject\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 69 code: C:\ProgramData\Jenkins\.jenkins\workspace\テスト\システムテスト\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe  --browser "chrome" --language-binding csharp --output json
Standard Output >>
{
  "logs": [
    {
      "level": "ERROR",
      "timestamp": 1716365603,
      "message": "Driver unavailable: Driver path: "
    }
  ],
  "result": {
    "code": 69,
    "message": "Driver unavailable: Driver path: ",
    "driver_path": "",
    "browser_path": ""
  }
}

<<

  Stack trace:
     at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
   at OpenQA.Selenium.SeleniumManager.BinaryPaths(String arguments)
   at OpenQA.Selenium.DriverFinder.BinaryPaths()
   at OpenQA.Selenium.DriverFinder.GetDriverPath()
   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)

Operating System

Windows Server 2022

Selenium version

4.21.0

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

Chrome 125

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

4.21.0

Are you using Selenium Grid?

No response

Copy link

github-actions bot commented Jun 3, 2024

@matsuda-dcom, 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

@bonigarcia does this look like it is output from the manager, (i.e., not the bindings)? Are there unit tests for these characters?

@bonigarcia
Copy link
Member

Similar issues were reported in the past. When that happened, I tested the Rust side with a custom cache path with non-ASCII characters, and the Rust side worked as expected. But those tests I did were manual, i.e., not included in an automated test. So, I have just included some parameterized automated tests about using paths with similar characters. The Windows build is failing in CI, but for other reasons. The new tests should work.

However, the reported problem comes from Rust. Unfortunately, the error message is not very informative due to a problem with the error message (solved here).

In summary, I don't know why this problem happens to @matsuda-dcom.

@matsuda-dcom: Can you please execute the following command from your shell and share the output here? Thanks

C:\ProgramData\Jenkins\.jenkins\workspace\テスト\システムテスト\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe --browser chrome --debug

@matsuda-dcom
Copy link
Author

@bonigarcia
This is the command execution result.

C:\Users\Administrator> C:\Users\Administrator> C:\ProgramData\Jenkins\.jenkins\workspace\テスト\システムテスト\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe --browser chrome --debug
[2024-06-05T04:02:36.769Z DEBUG] Sending stats to Plausible: Props { browser: "chrome", browser_version: "", os: "windows", arch: "amd64", lang: "", selenium_version: "4.21" }
[2024-06-05T04:02:36.866Z DEBUG] chromedriver not found in PATH
[2024-06-05T04:02:36.868Z DEBUG] chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
[2024-06-05T04:02:36.868Z DEBUG] Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value
[2024-06-05T04:02:37.187Z DEBUG] Output: "\r\r\n\r\r\nVersion=125.0.6422.142\r\r\n\r\r\n\r\r\n\r"
[2024-06-05T04:02:37.190Z DEBUG] Detected browser: chrome 125.0.6422.142
[2024-06-05T04:02:37.192Z DEBUG] Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
[2024-06-05T04:02:37.227Z DEBUG] Required driver: chromedriver 125.0.6422.141
[2024-06-05T04:02:37.227Z DEBUG] chromedriver 125.0.6422.141 already in the cache
[2024-06-05T04:02:37.228Z INFO ] Driver path: C:\Users\Administrator\.cache\selenium\chromedriver\win64\125.0.6422.141\chromedriver.exe
[2024-06-05T04:02:37.228Z INFO ] Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

This is the result of executing with a path that does not contain multibyte characters.

C:\Users\Administrator> C:\ProgramData\Jenkins\.jenkins\workspace\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe --browser "chrome" --debug
[2024-06-05T04:11:10.734Z DEBUG] chromedriver not found in PATH
[2024-06-05T04:11:10.744Z DEBUG] chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
[2024-06-05T04:11:10.745Z DEBUG] Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value
[2024-06-05T04:11:10.918Z DEBUG] Output: "\r\r\n\r\r\nVersion=125.0.6422.142\r\r\n\r\r\n\r\r\n\r"
[2024-06-05T04:11:10.920Z DEBUG] Detected browser: chrome 125.0.6422.142
[2024-06-05T04:11:10.923Z DEBUG] Required driver: chromedriver 125.0.6422.141
[2024-06-05T04:11:10.924Z DEBUG] chromedriver 125.0.6422.141 already in the cache
[2024-06-05T04:11:10.924Z INFO ] Driver path: C:\Users\Administrator\.cache\selenium\chromedriver\win64\125.0.6422.141\chromedriver.exe
[2024-06-05T04:11:10.925Z INFO ] Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

@matsuda-dcom
Copy link
Author

I found the same issue on the web.
https://harostudio.co.kr/selenium-exception-nosuchdriverexception-%ED%95%B4%EA%B2%B0-%EB%B0%A9%EB%B2%95/
My case is Japanese, but this case is Hangul.

@matsuda-dcom
Copy link
Author

matsuda-dcom commented Jun 5, 2024

If I change the nuget version back to 4.10.0 the test passes.

MyProject.csproj
-    <PackageReference Include="Selenium.Support" Version="4.21.0" />
-    <PackageReference Include="Selenium.WebDriver" Version="4.21.0" />
+    <PackageReference Include="Selenium.Support" Version="4.10.0" />
+    <PackageReference Include="Selenium.WebDriver" Version="4.10.0" />

@bonigarcia
Copy link
Member

According to the command execution output, Selenium Manager seems to work as expected. So, I still do not understand why this error is happening.

@matsuda-dcom: Please turn on logging and re-run your code. Information on how to adjust logs for your language can be found in our Troubleshooting documentation.

Also, you can update your Selenium Manager binary to get a better error description. I mean, replace the following file:

C:\ProgramData\Jenkins.jenkins\workspace\テスト\システムテスト\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe

With the one downloaded from here: selenium-manager-windows (you need to uncompress that ZIP file and replace the previous EXE file). Thanks.

@titusfortner
Copy link
Member

The first log, with the execution from a path that contains multibyte characters, appears to do the right thing.
Is your problem intermittent or consistent?
Try rerunning with --clear-cache so we can see if it is an issue with the first time it is run.

@matsuda-dcom
Copy link
Author

@bonigarcia
I turned on logging.
"Selenium.log" was created but is empty.
I tried for 5 hours and it didn't work. Is #13839 related?

Log.SetLevel(LogEventLevel.Trace).Handlers.Add(new ConsoleLogHandler());
Log.CreateContext(LogEventLevel.Trace).Handlers.Add(new FileLogHandler("Selenium.log", true));

Debug logs are output to the console.
�e�X�g\\�V�X�e���e�X�g Does the garbled characters have something to do with this error?

   OpenQA.Selenium.WebDriverException : Error starting process: C:\ProgramData\Jenkins\.jenkins\workspace\テスト\システムテスト\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe  --browser "chrome" --language-binding csharp --output json --debug
---- OpenQA.Selenium.WebDriverException : Selenium Manager process exited abnormally with 69 code: C:\ProgramData\Jenkins\.jenkins\workspace\テスト\システムテスト\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe  --browser "chrome" --language-binding csharp --output json --debug
Standard Output >>
{
  "logs": [
    {
      "level": "DEBUG",
      "timestamp": 1717738749,
      "message": "Found chromedriver 125.0.6422.76 in PATH: C:\\ProgramData\\Jenkins\\.jenkins\\workspace\\�e�X�g\\�V�X�e���e�X�g\\MyProject\\bin\\Debug\\net8.0\\chromedriver.exe"
    },
    {
      "level": "DEBUG",
      "timestamp": 1717738749,
      "message": "chrome detected at C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
    },
    {
      "level": "DEBUG",
      "timestamp": 1717738749,
      "message": "Running command: wmic datafile where name='C:\\\\Program Files\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe' get Version /value"
    },
    {
      "level": "DEBUG",
      "timestamp": 1717738749,
      "message": "Output: \"\\r\\r\\n\\r\\r\\nVersion=125.0.6422.142\\r\\r\\n\\r\\r\\n\\r\\r\\n\\r\""
    },
    {
      "level": "DEBUG",
      "timestamp": 1717738749,
      "message": "Detected browser: chrome 125.0.6422.142"
    },
    {
      "level": "DEBUG",
      "timestamp": 1717738749,
      "message": "Required driver: chromedriver 125.0.6422.141"
    },
    {
      "level": "ERROR",
      "timestamp": 1717738749,
      "message": "Driver unavailable: Driver path: "
    }
  ],
  "result": {
    "code": 69,
    "message": "Driver unavailable: Driver path: ",
    "driver_path": "",
    "browser_path": ""
  }
}

@matsuda-dcom
Copy link
Author

@bonigarcia
I ran it with the new Selenium Manager binaries.

C:\Users\Administrator> C:\ProgramData\Jenkins\.jenkins\workspace\テスト\システムテスト\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager-windows.exe --browser chrome --debug
[2024-06-07T06:05:47.991Z DEBUG] Sending stats to Plausible: Props { browser: "chrome", browser_version: "", os: "windows", arch: "amd64", lang: "", selenium_version: "4.22-nightly" }
[2024-06-07T06:05:48.228Z DEBUG] chromedriver not found in PATH
[2024-06-07T06:05:48.229Z DEBUG] chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
[2024-06-07T06:05:48.230Z DEBUG] Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value
[2024-06-07T06:05:48.712Z DEBUG] Output: "\r\r\n\r\r\nVersion=125.0.6422.142\r\r\n\r\r\n\r\r\n\r"
[2024-06-07T06:05:48.714Z DEBUG] Detected browser: chrome 125.0.6422.142
[2024-06-07T06:05:48.717Z DEBUG] Required driver: chromedriver 125.0.6422.141
[2024-06-07T06:05:48.718Z DEBUG] chromedriver 125.0.6422.141 already in the cache
[2024-06-07T06:05:48.718Z INFO ] Driver path: C:\Users\Administrator\.cache\selenium\chromedriver\win64\125.0.6422.141\chromedriver.exe
[2024-06-07T06:05:48.719Z INFO ] Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

@matsuda-dcom
Copy link
Author

@titusfortner
consistent. I've never been successful.
I ran with "--clear-cache".

C:\Users\Administrator>C:\ProgramData\Jenkins\.jenkins\workspace\テスト\システムテスト\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe --browser chrome --debug --clear-cache
[2024-06-07T06:17:04.123Z DEBUG] Clearing cache at: C:\Users\Administrator\.cache\selenium
[2024-06-07T06:17:04.141Z DEBUG] Sending stats to Plausible: Props { browser: "chrome", browser_version: "", os: "windows", arch: "amd64", lang: "", selenium_version: "4.21" }
[2024-06-07T06:17:04.203Z DEBUG] chromedriver not found in PATH
[2024-06-07T06:17:04.204Z DEBUG] chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
[2024-06-07T06:17:04.204Z DEBUG] Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value
[2024-06-07T06:17:04.447Z DEBUG] Output: "\r\r\n\r\r\nVersion=125.0.6422.142\r\r\n\r\r\n\r\r\n\r"
[2024-06-07T06:17:04.449Z DEBUG] Detected browser: chrome 125.0.6422.142
[2024-06-07T06:17:04.451Z DEBUG] Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
[2024-06-07T06:17:04.486Z DEBUG] Required driver: chromedriver 125.0.6422.141
[2024-06-07T06:17:04.487Z DEBUG] Downloading chromedriver 125.0.6422.141 from https://storage.googleapis.com/chrome-for-testing-public/125.0.6422.141/win64/chromedriver-win64.zip
[2024-06-07T06:17:05.353Z INFO ] Driver path: C:\Users\Administrator\.cache\selenium\chromedriver\win64\125.0.6422.141\chromedriver.exe
[2024-06-07T06:17:05.353Z INFO ] Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

The error continues to occur. The problem is not resolved.

@matsuda-dcom
Copy link
Author

matsuda-dcom commented Jun 7, 2024

This error occurs with nuget version 4.11.0 and above.
No error occurs in nuget version 4.10.0.

MyProject.csproj
    <PackageReference Include="Selenium.Support" Version="4.11.0" />
    <PackageReference Include="Selenium.WebDriver" Version="4.11.0" />

@bonigarcia
Copy link
Member

The problem is that you have a driver in your PATH:

Found chromedriver 125.0.6422.76 in PATH: C:\\ProgramData\\Jenkins\\.jenkins\\workspace\\�e�X�g\\�V�X�e���e�X�g\\MyProject\\bin\\Debug\\net8.0\\chromedriver.exe"

Selenium-Manager detects this driver. Unfortunately, it cannot parse that driver's path properly because of the Japanese characters. I've been debugging this problem, and I have found that it is caused by the execution of the command where in Windows through Selenium Manager. After much digging into the issue, I believe I found a solution.

So, the following Selenium Manager binary should fix the issue: selenium-manager-windows

@matsuda-dcom: Please download that file, uncompress it, and replace the resulting EXE with the one that is being used in your test:

C:\ProgramData\Jenkins.jenkins\workspace\テスト\システムテスト\MyProject\bin\Debug\net8.0\selenium-manager\windows\selenium-manager.exe

Please rerun your test and share the results here, thanks.

@matsuda-dcom
Copy link
Author

@bonigarcia
Replaced with selenium-manager-windows
No errors are output.
My Jenkins job was successful!
Thanks for the great fix.

@harsh4182
Copy link

@bonigarcia Can we have quick call? I am still facing issue . You can call me on whatsapp +919404918953

Copy link

github-actions bot commented Aug 2, 2024

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 Aug 2, 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