Skip to content

Conversation

@bonigarcia
Copy link
Member

@bonigarcia bonigarcia commented Oct 17, 2023

Description

This PR implements a couple of new arguments in Selenium Manager:

  • --skip_driver_in_path: For not using the drivers found in the PATH.
  • --skip_browser_in_path: For not using the browsers found in the PATH.

As usual, these arguments can be enabled using the config file or environment variables (e.g., SE_SKIP_DRIVER_IN_PATH=true).

The following executions showcase its use:

Usual execution with (incompatible) driver in path:

./selenium-manager --browser chrome --debug
DEBUG   Found chromedriver 107.0.5304.62 in PATH: C:\Users\boni\Documents\bat\chromedriver.exe
DEBUG   chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
DEBUG   Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value
DEBUG   Output: "\r\r\n\r\r\nVersion=118.0.5993.70\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: chrome 118.0.5993.70
DEBUG   Required driver: chromedriver 118.0.5993.70
WARN    The chromedriver version (107.0.5304.62) detected in PATH at C:\Users\boni\Documents\bat\chromedriver.exe might not be compatible with the detected chrome version (118.0.5993.70); currently, chromedriver 118.0.5993.70 is recommended for chrome 118.*, so it is advised to delete the driver in PATH and retry
INFO    Driver path: C:\Users\boni\Documents\bat\chromedriver.exe
INFO    Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

Same execution with (incompatible) driver in the path but using --skip_driver_in_path:

./selenium-manager --browser chrome --debug --skip-driver-in-path
DEBUG   Found chromedriver 107.0.5304.62 in PATH: C:\Users\boni\Documents\bat\chromedriver.exe
DEBUG   chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
DEBUG   Running command: wmic datafile where name='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' get Version /value
DEBUG   Output: "\r\r\n\r\r\nVersion=118.0.5993.70\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: chrome 118.0.5993.70
DEBUG   Required driver: chromedriver 118.0.5993.70
WARN    The chromedriver version (107.0.5304.62) detected in PATH at C:\Users\boni\Documents\bat\chromedriver.exe might not be compatible with the detected chrome version (118.0.5993.70); currently, chromedriver 118.0.5993.70 is recommended for chrome 118.*, so it is advised to delete the driver in PATH and retry
DEBUG   Skipping chromedriver in path: C:\Users\boni\Documents\bat\chromedriver.exe
DEBUG   chromedriver 118.0.5993.70 already in the cache
INFO    Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\118.0.5993.70\chromedriver.exe
INFO    Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

Motivation and Context

Although this is not the usual use case, it might be helpful for some users (e.g., #12957).

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 the C-rust Rust code is mostly Selenium Manager label Oct 17, 2023
@diemol
Copy link
Member

diemol commented Oct 17, 2023

This makes sense. It would leave SM ready for Selenium 5. As in, SM takes care of everything and users need to opt out if they do not want it.

@titusfortner
Copy link
Member

Is the plan that these reflect the desired behavior for 5 and we will toggle the default from false to true?

@bonigarcia
Copy link
Member Author

Is the plan that these reflect the desired behavior for 5 and we will toggle the default from false to true?

I think so.

@codecov-commenter
Copy link

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (dfacbe0) 56.49% compared to head (0340853) 56.49%.

❗ Current head 0340853 differs from pull request most recent head a9583c3. Consider uploading reports for the commit a9583c3 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   #12960   +/-   ##
=======================================
  Coverage   56.49%   56.49%           
=======================================
  Files          86       86           
  Lines        5255     5255           
  Branches      187      187           
=======================================
  Hits         2969     2969           
  Misses       2099     2099           
  Partials      187      187           

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

@titusfortner
Copy link
Member

How about one temporary toggle for --ignore-path that gets removed in Selenium 5 because it is the default behavior.

@titusfortner
Copy link
Member

actually, that's not true, we aren't going to ignore path in Selenium 5. what we need is to allow users to "opt-in" to Selenium 5 behavior, which means if what is found on PATH doesn't match, a driver will be downloaded.

We need one toggle of "enable selenium manager" to explicitly opt-in to Selenium 5 behavior
When it is off it always uses the driver in PATH even if it isn't correct
When it is on, it uses the driver in PATH only if it is correct and downloads otherwise

We can get rid of offline mode and use this instead, which will also make the error messages much more accurate.

Copy link
Member

@titusfortner titusfortner left a comment

Choose a reason for hiding this comment

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

I'm no on this pending the decision made in #12985

@bonigarcia
Copy link
Member Author

I am convinced this PR needs to be merged for the next Selenium Manager. In other words, merging this PR is independent of what you decide for Selenium 5.

Some users have asked for this feature, and we can provide a solution for them by simply merging this PR. For Selenium 5, we can get rid of these arguments or simply reuse the logic already implemented. However, the problem of using an incompatible driver in the PATH is real.

I have experienced the problem myself. Today I am preparing some examples for my talk tomorrow at the Selenium Open Space Conference. I created a basic repo example: https://github.com/bonigarcia/selenium-examples

The thing is, I created a basic test that uses the automated management capability provided by Selenium Manager, doing the following:

  ChromeOptions options = new ChromeOptions();
  options.setBrowserVersion("117");
  driver = new ChromeDriver(options);

Well, this test cannot be executed in GitHub Actions, since the workers have chromedriver 118 in its path, and Selenium Manager always uses it. As a result, my test using Chrome 117 cannot be executed in any way:

Error:    ChromeVersionTest.setup:37 » SessionNotCreated Could not start a new session. Response code 500. Message: session not created: This version of ChromeDriver only supports Chrome version 118
[1470](https://github.com/bonigarcia/selenium-examples/actions/runs/6670148598/job/18129435516#step:5:1471)Current browser version is 117.0.5938.149 with binary path /home/runner/.cache/selenium/chrome/linux64/117.0.5938.149/chrome 

You can see the execution here: https://github.com/bonigarcia/selenium-examples/actions/runs/6670148598/job/18129435516

All in all, this feature is a must today, independently of Selenium 5.

@titusfortner
Copy link
Member

Right, I'm saying if a user opts in to Selenium 5 behavior, then the value passed in to the browserVersion must always be respected regardless of what is on PATH. Local is used if it matches, and it is downloaded otherwise.

I'm concerned about continuing to add flags to support beta behavior rather than for what we want to see in released product. This should allow us to simplify the code.

@titusfortner
Copy link
Member

And I'm not suggesting we wait for Selenium 5. I'm saying we should allow people to get Selenium 5 behavior with a flag that can be removed when we actually release Selenium 5.

@titusfortner
Copy link
Member

We can revisit this if #13159 is not sufficient. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-rust Rust code is mostly Selenium Manager

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants