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 Manager not getting Chromium version number #11884

Closed
titusfortner opened this issue Apr 11, 2023 · 15 comments
Closed

[🐛 Bug]: Selenium Manager not getting Chromium version number #11884

titusfortner opened this issue Apr 11, 2023 · 15 comments

Comments

@titusfortner
Copy link
Member

titusfortner commented Apr 11, 2023

What happened?

Trying to use a chromium implementation instead of Chrome. I believe this feature is currently only implemented in Ruby.

Finally got it tested on Mac and it is working, so just a Windows issue.

How can we reproduce the issue?

options = Selenium::WebDriver::Options.chrome(binary: 'C:\chrome-win\chrome.exe')
    driver = Selenium::WebDriver.for :chrome, options: options

Relevant log output

2023-04-11 13:48:57 WARN Selenium applicable driver not found; attempting to install with Selenium Manager
2023-04-11 13:48:57 DEBUG Selenium Selenium Manager found at C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.8.6/bin/windows/selenium-manager.exe
2023-04-11 13:48:57 DEBUG Selenium Executing Process ["C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.8.6/bin/windows/selenium-manager.exe", "--browser", "chrome", "--output", "json", "--browser-path", "C:\\chrome-win\\chrome.exe", "--debug"]
2023-04-11 13:48:57 DEBUG Selenium Using shell command to find out chrome version
2023-04-11 13:48:57 DEBUG Selenium Running command: "wmic datafile where name='C:\\chrome-win\\chrome.exe' get Version /value"
2023-04-11 13:48:57 DEBUG Selenium Output: "\r\r\n\r\r\n\r"
2023-04-11 13:48:57 DEBUG Selenium The version of chrome cannot be detected. Trying with latest driver version

Operating System

Windows 11

Selenium version

Ruby 4.8.6

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

Chromium 107

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

n/a

Are you using Selenium Grid?

n/a

@titusfortner
Copy link
Member Author

And, never mind, it is an issue of how Ruby is parsing the JSON output...

@titusfortner
Copy link
Member Author

Ok, so, the debug info from Ruby is showing an empty response, but the json output from executing from the command line:

C:\projects\selenium\common\manager\windows>selenium-manager --browser chrome --browser-path "C:\\chrome-win\\chrome.exe" --output json --debug
{
  "logs": [
    {
      "level": "DEBUG",
      "timestamp": 1681240928,
      "message": "Using shell command to find out chrome version"
    },
    {
      "level": "DEBUG",
      "timestamp": 1681240928,
      "message": "Running command: \"wmic datafile where name='C:\\\\\\\\chrome-win\\\\\\\\chrome.exe' get Version /value\""
    },
    {
      "level": "DEBUG",
      "timestamp": 1681240928,
      "message": "Output: \"\\r\\r\\n\\r\\r\\nVersion=114.0.5710.0\\r\\r\\n\\r\\r\\n\\r\\r\\n\\r\""
    },
    {
      "level": "DEBUG",
      "timestamp": 1681240928,
      "message": "The version of chrome is 114.0.5710.0"
    },

So, probably a Ruby issue, but only in Windows? but maybe something in Rust?

@titusfortner
Copy link
Member Author

Ah, I see, the backslashes need to be escaped again for Windows ☹️

@titusfortner
Copy link
Member Author

@p0deje should we just replace:
https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver/common/selenium_manager.rb#L50

with:

            command << options.binary.gsub("\\", "\\\\\\")

@p0deje
Copy link
Member

p0deje commented Apr 12, 2023

@titusfortner Do we need to pass the binary file path as C:\chrome-win\chrome.exe or C:/chrome-win/chrome.exe? I remember we tested selenium-manager from Ruby + Windows on SeleniumConf. Could it be regression in 1a22a8b? Does it work in 4.8,3?

@titusfortner
Copy link
Member Author

Forward slashes do not work:

2023-04-12 09:43:31 DEBUG Selenium Running command: "wmic datafile where name='C:/chrome-win/chrome.exe' get Version /value"
2023-04-12 09:43:31 DEBUG Selenium Output: "\r\r\n\r\r\n\r"

The #gsub code above results in:

2023-04-12 09:44:40 DEBUG Selenium Running command: "wmic datafile where name='C:\\\\chrome-win\\\\chrome.exe' get Version /value"
2023-04-12 09:44:40 DEBUG Selenium Output: "\r\r\n\r\r\nVersion=114.0.5710.0\r\r\n\r\r\n\r\r\n\r"

@titusfortner
Copy link
Member Author

No, 4.8.3 does not work either.

I'm testing with an older version of Chromium that doesn't work with the latest chromedriver. Selenium Manager uses the latest driver by default, which means it might work by accident.

@p0deje
Copy link
Member

p0deje commented Apr 18, 2023

@titusfortner How do you make it work from CLI? I cannot seem to find a combination of slashes that would actually work for me:

PS C:\selenium> common\manager\windows\selenium-manager.exe --browser chrome --output json --browser-path "C:\\Program\ Files\\Google\\Chrome\\Application\\chrome.exe" --debug    
...
    {
      "level": "DEBUG",
      "timestamp": 1681832757,
      "message": "Running command: \"wmic datafile where name='C:\\\\\\\\Program\\\\ Files\\\\\\\\Google\\\\\\\\Chrome\\\\\\\\Application\\\\\\\\chrome.exe' get Version /value\""
    },
    {
      "level": "DEBUG",
      "timestamp": 1681832758,
      "message": "Output: \"\\r\\r\\n\\r\\r\\n\\r\""
    },
    {
      "level": "DEBUG",
      "timestamp": 1681832758,
      "message": "The version of chrome cannot be detected. Trying with latest driver version"
    },

@titusfortner
Copy link
Member Author

Umm, not sure command line, do you need to escape anything?

In Ruby, I got this working: command << options.binary.gsub("\\", "\\\\\\")

@titusfortner titusfortner added this to the 4.9 milestone Apr 18, 2023
@p0deje
Copy link
Member

p0deje commented Apr 18, 2023

Can you try making it work from CLI in Windows?

@p0deje
Copy link
Member

p0deje commented Apr 18, 2023

What I'm trying to figure out is whether we should fix it in Rust code rather than escaping in all bindings if it doesn't work from CLI.

@diemol
Copy link
Member

diemol commented Apr 19, 2023

Ideally the escaping should be done by the tool that start the process? Like, blank spaces was the issue we saw in SeleniumConf.

@p0deje
Copy link
Member

p0deje commented Apr 19, 2023

Yes, it would probably be preferable, I'm just not sure what's the proper slashes combination we should support on Windows.

@titusfortner
Copy link
Member Author

I committed what worked for me. Should be good enough for 4.9.

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