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 Firefox management (#11680 and #11682) #12582

Merged
merged 16 commits into from
Aug 23, 2023
Merged

Conversation

bonigarcia
Copy link
Member

@bonigarcia bonigarcia commented Aug 22, 2023

Description

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

The minimum manageable Firefox versions by SM are the following (although it is improbable that ancient versions could be automated with Selenium):

  • Firefox in Windows: 13
  • Firefox in macOS: 4
  • Firefox in Linux: 4

Some examples:

$ ./selenium-manager --debug --browser firefox --browser-version stable
DEBUG	geckodriver not found in PATH
DEBUG	firefox detected at /usr/lib/firefox/firefox.sh
DEBUG	Running command: /usr/lib/firefox/firefox.sh -v
DEBUG	Output: "Mozilla Firefox 116.0.1"
DEBUG	Detected browser: firefox 116.0.1
DEBUG	Discovered online firefox version (116) is the same as the detected local firefox version
DEBUG	Required driver: geckodriver 0.33.0
DEBUG	Downloading geckodriver 0.33.0 from https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz
INFO	Driver path: /home/boni/.cache/selenium/geckodriver/linux64/0.33.0/geckodriver
INFO	Browser path: /usr/lib/firefox/firefox.sh
$ ./selenium-manager --debug --browser firefox --browser-version beta
DEBUG	geckodriver not found in PATH
DEBUG	firefox detected at /usr/lib/firefox/firefox.sh
DEBUG	Running command: /usr/lib/firefox/firefox.sh -v
DEBUG	Output: "Mozilla Firefox 116.0.1"
DEBUG	Detected browser: firefox 116.0.1
DEBUG	Discovered online firefox version (117) is different to the detected local firefox version (116)
DEBUG	Required browser: firefox 117.0b9
DEBUG	Downloading firefox 117.0b9 from https://ftp.mozilla.org/pub/firefox/releases/117.0b9/linux-x86_64/en-US/firefox-117.0b9.tar.bz2
DEBUG	firefox 117.0b9 has been downloaded at /home/boni/.cache/selenium/firefox/linux64/117.0b9/firefox
DEBUG	Required driver: geckodriver 0.33.0
DEBUG	geckodriver 0.33.0 already in the cache
INFO	Driver path: /home/boni/.cache/selenium/geckodriver/linux64/0.33.0/geckodriver
INFO	Browser path: /home/boni/.cache/selenium/firefox/linux64/117.0b9/firefox
$ ./selenium-manager --debug --browser firefox --browser-version 80
DEBUG	geckodriver not found in PATH
DEBUG	firefox detected at /usr/lib/firefox/firefox.sh
DEBUG	Running command: /usr/lib/firefox/firefox.sh -v
DEBUG	Output: "Mozilla Firefox 116.0.1"
DEBUG	Detected browser: firefox 116.0.1
DEBUG	Discovered browser version (116) different to specified browser version (80)
DEBUG	Required browser: firefox 80.0.1
DEBUG	Downloading firefox 80.0.1 from https://ftp.mozilla.org/pub/firefox/releases/80.0.1/linux-x86_64/en-US/firefox-80.0.1.tar.bz2
DEBUG	firefox 80.0.1 has been downloaded at /home/boni/.cache/selenium/firefox/linux64/80.0.1/firefox
DEBUG	Required driver: geckodriver 0.33.0
DEBUG	geckodriver 0.33.0 already in the cache
INFO	Driver path: /home/boni/.cache/selenium/geckodriver/linux64/0.33.0/geckodriver
INFO	Browser path: /home/boni/.cache/selenium/firefox/linux64/80.0.1/firefox

As a plus, this PR includes a new argument called --avoid-browser-download, which prevents browser download even when the browser version is specified. This argument is irrelevant to the bindings. I implemented it to ease some tests and just in case someone using SM as a CLI tool needs it (like --force-browser-download).

Motivation and Context

This PR implements #11680 and #11682, and 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 merged commit f6bd738 into trunk Aug 23, 2023
@bonigarcia bonigarcia deleted the sm_firefox branch August 23, 2023 13:28
CandorContent pushed a commit to CandorContent/selenium that referenced this pull request Aug 25, 2023
…11682) (SeleniumHQ#12582)

* [rust] Automated Firefox management (Linux) (SeleniumHQ#11680)

* [rust] Automated Firefox management (macOS) (SeleniumHQ#11680)

* [rust] Automated Firefox management (Windows) (SeleniumHQ#11680)

* [rust] Refactoring and improving logs

* [rust] Include test for downloading latest Firefox version

* [rust] SM downloads fixed version of Firefox browser (SeleniumHQ#11682)

* [rust] Update cargo lock file

* [rust] Complete automated Firefox management when a version is specified

* [rust] Include argument --avoid-browser-download

* [rust] Error in unsupported browser download functions in different modules

* [rust] Include logic to uncompress dmg files (required in Firefox nightly in macOS)

* [rust] Improve command to move pkg payload

* [rust] Support downloading Firefox versions lower than 68

* [rust] Improve condition to display warning due to driver in path

* [rust] Rename resolve driver function to setup

* [rust] Replace crate bzip2-rs with bzip2
titusfortner added a commit that referenced this pull request Aug 27, 2023
titusfortner added a commit that referenced this pull request Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant