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] Support for Chromium (#12511) #12890

Merged
merged 2 commits into from
Oct 7, 2023
Merged

[rust] Support for Chromium (#12511) #12890

merged 2 commits into from
Oct 7, 2023

Conversation

bonigarcia
Copy link
Member

@bonigarcia bonigarcia commented Oct 6, 2023

Description

This PR includes support for detecting Chromium when Chrome is not available. Resolves #12511.

I've analyzed how Chromium is released. Like CfT, Chromium is released as portable binaries, distributed as zip files for Windows, Linux, and macOS (see Chromium download page). This way, it is not a standard way to detect if Chromium is "installed" in a given machine. Moreover, the Chromium executable file is called "chrome" (chrome.exe in Windows), like Chrome.

Nevertheless, there is a case in which Chromium is actually installed in the system. This might happen in Ubuntu systems, installing Chromium through atp or snap, for instance as follows:

sudo snap install chromium

When that happens, Chromium can be found by analyzing the PATH. In these cases, the Chromium binaries can be chromium-browser or chromium (see discussion).

Therefore, when Chrome is not discovered, this PR looks for these binaries in the PATH.

The following snippet showcases how this feature works in a Linux machine in which Chrome is not available but Chromium has been installed through snap:

./selenium-manager --browser chrome --debug

DEBUG    chromedriver not found in PATH
DEBUG    Found chromium in PATH: /snap/bin/chromium
DEBUG    Running command: /snap/bin/chromium --version
DEBUG    Output: "Chromium 117.0.5938.149 snap"
DEBUG    Detected browser: chrome 117.0.5938.149
DEBUG    Required driver: chromedriver 117.0.5938.149
DEBUG    chromedriver 117.0.5938.149 already in the cache
INFO    Driver path: /home/user/.cache/selenium/chromedriver/linux64/117.0.5938.149/chromedriver
INFO    Browser path: /snap/bin/chromium

Motivation and Context

This PR implements #12511. Also, this feature will allow to prevent issues like reported in #12828.

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 Oct 6, 2023
@titusfortner titusfortner removed this from the 4.14 milestone Oct 6, 2023
@titusfortner titusfortner merged commit 73cfa22 into trunk Oct 7, 2023
48 of 51 checks passed
@titusfortner titusfortner deleted the sm_chromium branch October 7, 2023 12:13
aguspe pushed a commit to aguspe/selenium that referenced this pull request Oct 22, 2023
[rust] Detect chromium browser in path (SeleniumHQ#12511)

Co-authored-by: Titus Fortner <[email protected]>
floehopper added a commit to alphagov/signon that referenced this pull request Feb 16, 2024
We've been seeing the following error running the Jasmine specs in a
govuk-docker container running on Apple silicon:

    SessionNotCreatedError: session not created:
      Chrome failed to start: exited normally.

For a full diagnosis of the problem see this govuk-docker PR [1] which
was a first attempt at fixing the problem.

Note that the problem was also triggering a warning like the following
even on non-Apple silicon:

    The chromedriver version (120.0.6099.199) detected in PATH at
    /usr/bin/chromedriver might not be compatible with the detected chrome
    version (121.0.6167.85); currently, chromedriver 121.0.6167.85 is
    recommended for chrome 121.*, so it is advised to delete the driver in
    PATH and retry

This PR forces yarn to install v4.17.0 of the `selenium-webdriver` node
package which includes a fix [2] to the `selenium-manager` CLI app
included in the `selenium-webdriver` node package so that it now
correctly finds the chromium binary. This fixes both the error on Apple
silicon and the warning on all devices.

[1]: alphagov/govuk-docker#724
[2]: SeleniumHQ/selenium#12890
floehopper added a commit to floehopper/jasmine-browser-runner that referenced this pull request Feb 16, 2024
To include this fix [1] for correct detection of a chromium binary.

[1]: SeleniumHQ/selenium#12890
floehopper added a commit to alphagov/signon that referenced this pull request Feb 16, 2024
We've been seeing the following error running the Jasmine specs in a
govuk-docker container running on Apple silicon:

    SessionNotCreatedError: session not created:
      Chrome failed to start: exited normally.

For a full diagnosis of the problem see this govuk-docker PR [1] which
was a first attempt at fixing the problem.

Note that the problem was also triggering a warning like the following
even on non-Apple silicon:

    The chromedriver version (120.0.6099.199) detected in PATH at
    /usr/bin/chromedriver might not be compatible with the detected chrome
    version (121.0.6167.85); currently, chromedriver 121.0.6167.85 is
    recommended for chrome 121.*, so it is advised to delete the driver in
    PATH and retry

This PR forces yarn to install v4.17.0 of the `selenium-webdriver` node
package which includes a fix [2] to the `selenium-manager` CLI app
included in the `selenium-webdriver` node package so that it now
correctly finds the chromium binary. This fixes both the error on Apple
silicon and the warning on all devices.

[1]: alphagov/govuk-docker#724
[2]: SeleniumHQ/selenium#12890
richardTowers added a commit to alphagov/whitehall that referenced this pull request Feb 16, 2024
We've been seeing the following error running the Jasmine specs in a
govuk-docker container running on Apple silicon:

    SessionNotCreatedError: session not created:
      Chrome failed to start: exited normally.

For a full diagnosis of the problem see this govuk-docker PR [1] which
was a first attempt at fixing the problem.

Note that the problem was also triggering a warning like the following
even on non-Apple silicon:

    The chromedriver version (120.0.6099.199) detected in PATH at
    /usr/bin/chromedriver might not be compatible with the detected chrome
    version (121.0.6167.85); currently, chromedriver 121.0.6167.85 is
    recommended for chrome 121.*, so it is advised to delete the driver in
    PATH and retry

This PR forces yarn to install v4.17.0 of the `selenium-webdriver` node
package which includes a fix [2] to the `selenium-manager` CLI app
included in the `selenium-webdriver` node package so that it now
correctly finds the chromium binary. This fixes both the error on Apple
silicon and the warning on all devices.

[1]: alphagov/govuk-docker#724
[2]: SeleniumHQ/selenium#12890

Co-Authored-By: <[email protected]>
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.

[🚀 Feature]: Support for Chromium
2 participants