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] Automated Edge management (#11681 and #11683) #12835

Merged
merged 35 commits into from
Oct 7, 2023

Conversation

bonigarcia
Copy link
Member

@bonigarcia bonigarcia commented Sep 29, 2023

Description

This PR implements Edge's automated browser management feature for the latest (stable) and given versions (unstable -beta, dev, nightly- and fixed versions -e.g., 116, 117, etc.-).

This feature for macOS and Linux works the same way as CfT and Firefox. In other words, the managed versions are stored in the cache folder. For instance:

In macOS:

boni@Bonis-iMac rust % cargo run -- --browser edge --debug --force-browser-download

DEBUG	msedgedriver not found in PATH
DEBUG	Checking edge releases on https://edgeupdates.microsoft.com/api/products
DEBUG	Required browser: edge 117.0.2045.40
DEBUG	Downloading edge 117.0.2045.40 from https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/6e65d9ef-0bb9-4636-8d9e-2b1b9d16149d/MicrosoftEdge-117.0.2045.40.pkg
DEBUG	edge 117.0.2045.40 has been downloaded at /Users/boni/.cache/selenium/edge/mac64/117.0.2045.40/Microsoft Edge.app/Contents/MacOS/Microsoft Edge
DEBUG	Reading msedgedriver version from https://msedgedriver.azureedge.net/LATEST_RELEASE_117_MACOS
DEBUG	Required driver: msedgedriver 117.0.2045.40
DEBUG	Downloading msedgedriver 117.0.2045.40 from https://msedgedriver.azureedge.net/117.0.2045.40/edgedriver_mac64.zip
INFO	Driver path: /Users/boni/.cache/selenium/msedgedriver/mac64/117.0.2045.40/msedgedriver
INFO	Browser path: /Users/boni/.cache/selenium/edge/mac64/117.0.2045.40/Microsoft Edge.app/Contents/MacOS/Microsoft Edge

In Linux:

user@ubuntu-vm:~/dev/selenium/rust$ cargo run -- --browser edge --debug --browser-version beta

DEBUG	msedgedriver not found in PATH
DEBUG	edge not found in PATH
DEBUG	edge beta not found in the system
DEBUG	Checking edge releases on https://edgeupdates.microsoft.com/api/products
DEBUG	Required browser: edge 118.0.2088.11
DEBUG	Downloading edge 118.0.2088.11 from https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-beta/microsoft-edge-beta_118.0.2088.11-1_amd64.deb
DEBUG	edge 118.0.2088.11 has been downloaded at /home/user/.cache/selenium/edge/linux64/118.0.2088.11/msedge
DEBUG	Reading msedgedriver version from https://msedgedriver.azureedge.net/LATEST_RELEASE_118_LINUX
DEBUG	Required driver: msedgedriver 118.0.2088.11
DEBUG	Downloading msedgedriver 118.0.2088.11 from https://msedgedriver.azureedge.net/118.0.2088.11/edgedriver_linux64.zip
INFO	Driver path: /home/user/.cache/selenium/msedgedriver/linux64/118.0.2088.11/msedgedriver
INFO	Browser path: /home/user/.cache/selenium/edge/linux64/118.0.2088.11/msedge

Nevertheless, the the Edge installer for Windows is distributed as an MSI file. I intended to extract the Edge binary from there, as I did with Firefox. But, the MSI installer has a different format this time, which I cannot extract. This Stack Overflow question summarizes the problem I'm facing.

Therefore, the only alternative I found is to install Edge in Windows through its MSI installer, requiring administrator permissions. So this is the way in which it is implemented in this PR. Some examples:

In Windows (without admin permissions):

C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --debug --browser edge --browser-version beta

DEBUG   msedgedriver not found in PATH
DEBUG   edge not found in PATH
DEBUG   edge beta not found in the system
WARN    There was an error managing edge (edge can only be installed in Windows with administrator permissions); using driver found in the cache
INFO    Driver path: C:\Users\boni\.cache\selenium\msedgedriver\win64\118.0.2088.17\msedgedriver.exe

In Windows (with admin permissions):

C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --debug --browser edge --browser-version beta

DEBUG   msedgedriver not found in PATH
DEBUG   edge not found in PATH
DEBUG   edge beta not found in the system
DEBUG   Checking edge releases on https://edgeupdates.microsoft.com/api/products
DEBUG   Required browser: edge 118.0.2088.17
DEBUG   Downloading edge 118.0.2088.17 from https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/7adec542-f34c-4dea-8e2a-f8c6fab4d2f3/MicrosoftEdgeBetaEnterpriseX64.msi
DEBUG   Installing MicrosoftEdgeBetaEnterpriseX64.msi
DEBUG   edge 118.0.2088.17 is available at C:\Program Files (x86)\Microsoft\Edge Beta\Application\msedge.exe
DEBUG   Required driver: msedgedriver 118.0.2088.17
DEBUG   msedgedriver 118.0.2088.17 already in the cache
INFO    Driver path: C:\Users\boni\.cache\selenium\msedgedriver\win64\118.0.2088.17\msedgedriver.exe
INFO    Browser path: C:\Program Files (x86)\Microsoft\Edge Beta\Application\msedge.exe

Motivation and Context

It has been tested on:

  • Windows (10)
  • Linux (Ubuntu 22.04.2 and 22.10)
  • macOS (Big Sur 11.0.1)

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 this to the 4.14 milestone Sep 29, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (ecfa9c4) 56.51% compared to head (eec720c) 56.51%.
Report is 1 commits behind head on trunk.

❗ Current head eec720c differs from pull request most recent head 8443a2b. Consider uploading reports for the commit 8443a2b to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #12835   +/-   ##
=======================================
  Coverage   56.51%   56.51%           
=======================================
  Files          86       86           
  Lines        5255     5255           
  Branches      187      187           
=======================================
  Hits         2970     2970           
  Misses       2098     2098           
  Partials      187      187           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@titusfortner
Copy link
Member

I wonder if we should be doing anything different to support non-admin installs (download msi and point to it in warning message), but this is probably the most correct obvious thing. I'm sure if people want more help they'll complain to us about it. 😂

@bonigarcia bonigarcia force-pushed the sm_edge_management branch 2 times, most recently from e87ad2b to 623acd5 Compare October 3, 2023 12:26
@titusfortner
Copy link
Member

@bonigarcia can you deconflict the files and we'll merge this.

@bonigarcia
Copy link
Member Author

I've rebased this branch. If CI is happy, it is ready to be merged.

@titusfortner
Copy link
Member

Something failing in RBE. Trying some things...

@titusfortner titusfortner removed this from the 4.14 milestone Oct 6, 2023
@titusfortner
Copy link
Member

Got the RBE tests to pass finally. But looks like something is broken for Windows. Looks rust build related.

@titusfortner
Copy link
Member

And it has magically fixed. Merging...

@titusfortner titusfortner merged commit 0f8e018 into trunk Oct 7, 2023
49 of 51 checks passed
@titusfortner titusfortner deleted the sm_edge_management branch October 7, 2023 14:43
@bonigarcia
Copy link
Member Author

And it has magically fixed. Merging...

@titusfortner: Did you discover the cause of the failure in the RBE build? In the end, it was not related to Rust, right?

@titusfortner
Copy link
Member

It went away after I updated the branch 🤷‍♂️

aguspe pushed a commit to aguspe/selenium that referenced this pull request Oct 22, 2023
…) (SeleniumHQ#12835)

* [rust] Automated Edge management (macOS) (SeleniumHQ#11681)

* [rust] Check also unstable versions for Edge management

* [rust] Include logic to check fixed versions of Edge

* [rust] Get browser url again if empty

* [rust] Include logic for stable label

* [rust] Automated Edge management (Linux) (SeleniumHQ#11681 and SeleniumHQ#11683)

* [rust] Fix paths used to extract edge

* [rust] Clean extract label and fix searched version

* [rust] Refactor logic for downloading browsers in a common function

* [rust] Install Edge in Windows through the MSI installer

* [rust] Check admin permissions in Windows before downloading MSI installer

* [rust] Use browser version in functions for requesting online repos

* [rust] Refactor common logic when unavailable download or discovery

* [rust] Fix condition checking Firefox nightly in mac

* [rust] Update cargo bazel lock file

* [rust] Separate function to ensure empty parent path before moving files

---------

Co-authored-by: titusfortner <[email protected]>
Co-authored-by: Titus Fortner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
3 participants