SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.08k stars 8.09k forks source link

Selenium Manager doesn’t find path with space in SE_CACHE_PATH environment variable #14234

Open clavinet opened 1 month ago

clavinet commented 1 month ago

What happened?

Selenium Manager on Windows doesn’t find a path containing the space character when this path is set as a Windows environment variable.

I have not tested it on Linux.

How can we reproduce the issue?

Set SE_CACHE_PATH as an environment variable on Windows with a path that contains space character.

Relevant log output

(default cache location is used)

Operating System

Windows 11

Selenium version

Microsoft JDK 17.0.11.9-hotspot

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

Chrome 126.0.6478.127 (not launched though)

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

Win32 114.0.5735.90

Are you using Selenium Grid?

No response

github-actions[bot] commented 1 month ago

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

clavinet commented 1 month ago

Addendum: space in path doesn’t seem to work either when cache-path=“c:\path with\space” is set in %userprofile%.cache\selenium\se-config.toml

bonigarcia commented 3 days ago

I checked this, and Selenium Manager is working fine. See an example when exporting the SE_CACHE_PATH:

set SE_CACHE_PATH=C:\Users\boni\.cache\selenium with spaces
> selenium-manager.exe --browser chrome --debug
[2024-08-24T20:21:48.090Z DEBUG] chromedriver not found in PATH
[2024-08-24T20:21:48.091Z DEBUG] chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
[2024-08-24T20:21:48.092Z DEBUG] Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value
[2024-08-24T20:21:48.170Z DEBUG] Output: "\r\r\n\r\r\nVersion=127.0.6533.120\r\r\n\r\r\n\r\r\n\r"
[2024-08-24T20:21:48.174Z DEBUG] Detected browser: chrome 127.0.6533.120
[2024-08-24T20:21:48.176Z DEBUG] Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
[2024-08-24T20:21:48.313Z DEBUG] Required driver: chromedriver 127.0.6533.119
[2024-08-24T20:21:48.314Z DEBUG] Downloading chromedriver 127.0.6533.119 from https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.119/win64/chromedriver-win64.zip
[2024-08-24T20:21:49.140Z INFO ] Driver path: C:\Users\boni\.cache\selenium with spaces\chromedriver\win64\127.0.6533.119\chromedriver.exe
[2024-08-24T20:21:49.141Z INFO ] Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

Selenium Manager also works well when the entry cache-path is defined in the se-config.toml. Notice that the TOML format requires escaping backslashes in strings. As explained in the doc:

For Windows paths in the TOML configuration file, double backslashes are required (e.g., C:\\custom\\cache).

For example:

cache-path = "C:\\Users\\boni\\.cache\\selenium and spaces"
> selenium-manager.exe --browser chrome --debug
[2024-08-24T20:24:08.904Z DEBUG] chromedriver not found in PATH
[2024-08-24T20:24:08.905Z DEBUG] chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
[2024-08-24T20:24:08.906Z DEBUG] Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value
[2024-08-24T20:24:08.974Z DEBUG] Output: "\r\r\n\r\r\nVersion=127.0.6533.120\r\r\n\r\r\n\r\r\n\r"
[2024-08-24T20:24:08.979Z DEBUG] Detected browser: chrome 127.0.6533.120
[2024-08-24T20:24:08.980Z DEBUG] Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
[2024-08-24T20:24:09.263Z DEBUG] Required driver: chromedriver 127.0.6533.119
[2024-08-24T20:24:09.264Z DEBUG] Downloading chromedriver 127.0.6533.119 from https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.119/win64/chromedriver-win64.zip
[2024-08-24T20:24:10.141Z INFO ] Driver path: C:\Users\boni\.cache\selenium and spaces\chromedriver\win64\127.0.6533.119\chromedriver.exe
[2024-08-24T20:24:10.141Z INFO ] Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe