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

[rust] Build selenium-manager for win32 (compatible when executed in win64) #11788

Merged
merged 3 commits into from
Apr 4, 2023

Conversation

bonigarcia
Copy link
Member

@bonigarcia bonigarcia commented Mar 17, 2023

Description

This PR updated the workflow to build Selenium Manager in GH Actions, for building selenium-manager for Windows x32. An example execution can be see here. I tested the resulting binary (e.g. selenium-manager_windows-x32) both in Windows x32 and x64. In both cases, it works as expected.

Motivation and Context

This PR is part of #11599. Since the resulting binary is compatible with win32 and win64, it can be used to replace the selenium-manager binary for windows (in the folder common/manager/windows).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@bonigarcia bonigarcia added C-build Build related issues (bazel and CI) C-rust labels Mar 17, 2023
@titusfortner
Copy link
Member

The Windows 32 binary appears to work on my 64bit Windows machine. Is there functionality that does not work? I feel like this was discussed but I don't remember what was said.

@bonigarcia
Copy link
Member Author

The selenium-manager x32 binary executed in an x64 machine has different issues. See an example:

C:\Users\boni\Downloads>selenium-manager.exe --browser firefox --debug --clear-cache
DEBUG   Clearing cache at: C:\Users\boni\.cache\selenium
DEBUG   Using shell command to find out firefox version
DEBUG   Running command: "wmic datafile where name='%PROGRAMFILES:\\=\\\\%\\\\Mozilla Firefox\\\\firefox.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\n\r"
DEBUG   Running command: "wmic datafile where name='%PROGRAMFILES(X86):\\=\\\\%\\\\Mozilla Firefox\\\\firefox.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\n\r"
DEBUG   The version of firefox cannot be detected. Trying with latest driver version
DEBUG   Required driver: geckodriver 0.32.2
DEBUG   Running command: "geckodriver --version"
DEBUG   Output: ""
DEBUG   Driver URL: https://github.com/mozilla/geckodriver/releases/download/v0.32.2/geckodriver-v0.32.2-win32.zip
DEBUG   File extracted to C:\Users\boni\.cache\selenium\geckodriver\win32\0.32.2\geckodriver.exe (3419040 bytes)
INFO    C:\Users\boni\.cache\selenium\geckodriver\win32\0.32.2\geckodriver.exe

As you can see, the commands to discover the browser version (Firefox, in this case) are not working. In the case of Chrome it works because of the registry command. But the WMIC command is more reliable (since we ask directly to the browser binary instead of the info in the registry). In addition, WMIC command is required when the browser path is passed from options.

The second problem has to do with architecture discover. As you can see in the example before, the binary geckodriver-v0.32.2-win32.zip is downloaded, but the target should be x64 since that is the host running selenium-manager.

Of course, it would be ideal to have a selenium-manager x32 binary that also works for x64. I have been working on that since Saturday. I don't have a complete solution, but I think I am close. I'll let you know my results.

@titusfortner
Copy link
Member

If we need another binary, we need it, I just wanted to make sure. Thanks for explaining it.

@bonigarcia bonigarcia force-pushed the se_mgr_build_win32 branch 4 times, most recently from f5a3683 to 6ddbdfb Compare March 21, 2023 12:33
@bonigarcia bonigarcia changed the title [CI] Build selenium-manager for win32 in GH Actions [rust] Build selenium-manager for win32 and compatible when executed in win64 Mar 21, 2023
@bonigarcia
Copy link
Member Author

I managed to make the resulting selenium-manager binary compatible with Windows 32 and 64. See for example: selenium-manager_windows-x32

Some output examples in Windows 64:

Chrome

C:\Users\boni\Downloads>selenium-manager --browser chrome --debug --clear-cache
DEBUG   Clearing cache at: C:\Users\boni\.cache\selenium
DEBUG   Using shell command to find out chrome version
DEBUG   Running command: "set PFILES=%PROGRAMFILES: (x86)=%&& wmic datafile where name='!PFILES:\\=\\\\!\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\nVersion=111.0.5563.65\r\r\n\r\r\n\r\r\n\r"
DEBUG   The version of chrome is 111.0.5563.65
DEBUG   Detected browser: chrome 111
DEBUG   Reading chromedriver version from https://chromedriver.storage.googleapis.com/LATEST_RELEASE_111
DEBUG   Required driver: chromedriver 111.0.5563.64
DEBUG   Running command: "chromedriver --version"
DEBUG   Output: ""
DEBUG   Driver URL: https://chromedriver.storage.googleapis.com/111.0.5563.64/chromedriver_win32.zip
DEBUG   File extracted to C:\Users\boni\.cache\selenium\chromedriver\win32\111.0.5563.64\chromedriver.exe (12765184 bytes)
INFO    C:\Users\boni\.cache\selenium\chromedriver\win32\111.0.5563.64\chromedriver.exe

Firefox

C:\Users\boni\Downloads>selenium-manager --browser firefox --debug --clear-cache
DEBUG   Clearing cache at: C:\Users\boni\.cache\selenium
DEBUG   Using shell command to find out firefox version
DEBUG   Running command: "set PFILES=%PROGRAMFILES: (x86)=%&& wmic datafile where name='!PFILES:\\=\\\\!\\\\Mozilla Firefox\\\\firefox.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\nVersion=110.0.0.8437\r\r\n\r\r\n\r\r\n\r"
DEBUG   The version of firefox is 110.0.0.8437
DEBUG   Detected browser: firefox 110
DEBUG   Required driver: geckodriver 0.32.2
DEBUG   Running command: "geckodriver --version"
DEBUG   Output: ""
DEBUG   Driver URL: https://github.com/mozilla/geckodriver/releases/download/v0.32.2/geckodriver-v0.32.2-win64.zip
DEBUG   File extracted to C:\Users\boni\.cache\selenium\geckodriver\win64\0.32.2\geckodriver.exe (3872672 bytes)
INFO    C:\Users\boni\.cache\selenium\geckodriver\win64\0.32.2\geckodriver.exe

Edge

C:\Users\boni\Downloads>selenium-manager --browser edge --debug --clear-cache
DEBUG   Clearing cache at: C:\Users\boni\.cache\selenium
DEBUG   Using shell command to find out edge version
DEBUG   Running command: "set PFILES=%PROGRAMFILES(X86)%&& wmic datafile where name='!PFILES:\\=\\\\!\\\\Microsoft\\\\Edge\\\\Application\\\\msedge.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\nVersion=111.0.1661.44\r\r\n\r\r\n\r\r\n\r"
DEBUG   The version of edge is 111.0.1661.44
DEBUG   Detected browser: edge 111
DEBUG   Reading msedgedriver version from https://msedgedriver.azureedge.net/LATEST_RELEASE_111_WINDOWS
DEBUG   Required driver: msedgedriver 111.0.1661.44
DEBUG   Running command: "msedgedriver --version"
DEBUG   Output: ""
DEBUG   Driver URL: https://msedgedriver.azureedge.net/111.0.1661.44/edgedriver_win64.zip
DEBUG   File extracted to C:\Users\boni\.cache\selenium\msedgedriver\win64\111.0.1661.44\msedgedriver.exe (17107928 bytes)
INFO    C:\Users\boni\.cache\selenium\msedgedriver\win64\111.0.1661.44\msedgedriver.exe

... and in Windows 32:

Chrome

C:\Users\user\Downloads>selenium-manager --browser chrome --debug --clear-cache
DEBUG   Clearing cache at: C:\Users\user\.cache\selenium
DEBUG   Using shell command to find out chrome version
DEBUG   Running command: "set PFILES=%PROGRAMFILES: (x86)=%&& wmic datafile where name='!PFILES:\\=\\\\!\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\nVersion=111.0.5563.65\r\r\n\r\r\n\r\r\n\r"
DEBUG   The version of chrome is 111.0.5563.65
DEBUG   Detected browser: chrome 111
DEBUG   Reading chromedriver version from https://chromedriver.storage.googleapis.com/LATEST_RELEASE_111
DEBUG   Required driver: chromedriver 111.0.5563.64
DEBUG   Running command: "chromedriver --version"
DEBUG   Output: ""
DEBUG   Driver URL: https://chromedriver.storage.googleapis.com/111.0.5563.64/chromedriver_win32.zip
DEBUG   File extracted to C:\Users\user\.cache\selenium\chromedriver\win32\111.0.5563.64\chromedriver.exe (12765184 bytes)
INFO    C:\Users\user\.cache\selenium\chromedriver\win32\111.0.5563.64\chromedriver.exe

Firefox

C:\Users\user\Downloads>selenium-manager --browser firefox --debug --clear-cache
DEBUG   Clearing cache at: C:\Users\user\.cache\selenium
DEBUG   Using shell command to find out firefox version
DEBUG   Running command: "set PFILES=%PROGRAMFILES: (x86)=%&& wmic datafile where name='!PFILES:\\=\\\\!\\\\Mozilla Firefox\\\\firefox.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\nVersion=111.0.0.8468\r\r\n\r\r\n\r\r\n\r"
DEBUG   The version of firefox is 111.0.0.8468
DEBUG   Detected browser: firefox 111
DEBUG   Required driver: geckodriver 0.32.2
DEBUG   Running command: "geckodriver --version"
DEBUG   Output: ""
DEBUG   Driver URL: https://github.com/mozilla/geckodriver/releases/download/v0.32.2/geckodriver-v0.32.2-win32.zip
DEBUG   File extracted to C:\Users\user\.cache\selenium\geckodriver\win32\0.32.2\geckodriver.exe (3419040 bytes)
INFO    C:\Users\user\.cache\selenium\geckodriver\win32\0.32.2\geckodriver.exe

Edge

C:\Users\user\Downloads>selenium-manager --browser edge --debug --clear-cache
DEBUG   Clearing cache at: C:\Users\user\.cache\selenium
DEBUG   Using shell command to find out edge version
DEBUG   Running command: "set PFILES=%PROGRAMFILES(X86)%&& wmic datafile where name='!PFILES:\\=\\\\!\\\\Microsoft\\\\Edge\\\\Application\\\\msedge.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\n\r"
DEBUG   Running command: "set PFILES=%PROGRAMFILES: (x86)=%&& wmic datafile where name='!PFILES:\\=\\\\!\\\\Microsoft\\\\Edge\\\\Application\\\\msedge.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\nVersion=106.0.1370.52\r\r\n\r\r\n\r\r\n\r"
DEBUG   The version of edge is 106.0.1370.52
DEBUG   Detected browser: edge 106
DEBUG   Reading msedgedriver version from https://msedgedriver.azureedge.net/LATEST_RELEASE_106_WINDOWS
DEBUG   Required driver: msedgedriver 106.0.1370.86
DEBUG   Running command: "msedgedriver --version"
DEBUG   Output: ""
DEBUG   Driver URL: https://msedgedriver.azureedge.net/106.0.1370.86/edgedriver_win32.zip
DEBUG   File extracted to C:\Users\user\.cache\selenium\msedgedriver\win32\106.0.1370.86\msedgedriver.exe (12613552 bytes)
INFO    C:\Users\user\.cache\selenium\msedgedriver\win32\106.0.1370.86\msedgedriver.exe

I updated the PR title and description accordingly.

@bonigarcia bonigarcia changed the title [rust] Build selenium-manager for win32 and compatible when executed in win64 [rust] Build selenium-manager for win32 (compatible when executed in win64) Mar 21, 2023
@titusfortner
Copy link
Member

This is great!

So, going off of this list: #11357

selenium-manager_windows-x32 works for win32 & win64
selenium-manager_macos-x64 works for mac64 & mac-arm64
selenium-manager_linux-x64 works for linux64

That's ~95% of use cases based on geckodriver numbers

The only weird bit here... the new windows 32 bit, on 64 bit machines it uses the 64 bit msedgedriver & geckodriver, but the 32 bit chromedriver? Or is it using 32 bit versions for everything?

Finally that means for #11599 all we need to do right now is to check for arm64 windows/linux and linux32 to throw an explicit error that the architecture isn't supported...

@bonigarcia
Copy link
Member Author

The only weird bit here... the new windows 32 bit, on 64 bit machines it uses the 64 bit msedgedriver & geckodriver, but the 32 bit chromedriver? Or is it using 32 bit versions for everything?

Yes, that is because chromedriver for Windows is only released as a x32 binary (see chromedriver page) which works both in x32 and x64 (just like the new selenium-manager binary for Windows).

@diemol
Copy link
Member

diemol commented Mar 29, 2023

I actually meant to post this comment here.

@titusfortner
Copy link
Member

Ah, then I meant to post this comment here as well.

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @bonigarcia!

@diemol diemol merged commit ec3ed70 into trunk Apr 4, 2023
9 checks passed
@diemol diemol deleted the se_mgr_build_win32 branch April 4, 2023 07:46
yashcho pushed a commit to yashcho/selenium that referenced this pull request Apr 7, 2023
…win64) (SeleniumHQ#11788)

* [CI] Build selenium-manager for win32 in GH Actions

* [CI] Remove build for selenium-manager win64 in GH Actions

* [rust] Enable browser version and architecture detection both in Windows x32 and x64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-build Build related issues (bazel and CI) C-rust
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants