Skip to content

[rust] Save discovered browser version (network request) in local metadata#12443

Merged
bonigarcia merged 3 commits intotrunkfrom
se_mgr_chrome_ttl
Jul 31, 2023
Merged

[rust] Save discovered browser version (network request) in local metadata#12443
bonigarcia merged 3 commits intotrunkfrom
se_mgr_chrome_ttl

Conversation

@bonigarcia
Copy link
Copy Markdown
Member

Description

This PR allows to save discovered browser version (using a network request to the CfT endpoints) in the local metadata (i.e., ~/.cache/selenium/selenium-manager.json) using the value of TTL_browsers (i.e., 1 hour).

Motivation and Context

This PR probably will make CI Java green again. But the problems detected in the Java tests (invalid proxy and creation of multiple WebDriver objects) are still there.

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 Jul 29, 2023
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jul 29, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (2580fc6) 57.37% compared to head (ed4133c) 57.39%.
Report is 1 commits behind head on trunk.

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

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #12443      +/-   ##
==========================================
+ Coverage   57.37%   57.39%   +0.01%     
==========================================
  Files          86       86              
  Lines        5366     5368       +2     
  Branches      206      206              
==========================================
+ Hits         3079     3081       +2     
  Misses       2081     2081              
  Partials      206      206              
Files Changed Coverage Δ
py/selenium/webdriver/common/selenium_manager.py 57.74% <100.00%> (+1.22%) ⬆️

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

@bonigarcia
Copy link
Copy Markdown
Member Author

I have just sent a second commit to this PR to distinguish between the "stable" label for browser-version and blank ("") (i.e., not specified). This way, the additional network request required to discover the online stable version is only done when the "stable" label is used. Here it is some output examples:

Not specifying browser version (first time)

C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --browser chrome --debug
   Compiling selenium-manager v1.0.0-M4 (C:\Users\boni\Documents\dev\selenium\rust)
    Finished dev [unoptimized + debuginfo] target(s) in 3.51s
     Running `target\debug\selenium-manager.exe --browser chrome --debug`
DEBUG   Checking chromedriver in PATH
DEBUG   Running command: chromedriver --version
DEBUG   Output: ""
DEBUG   chromedriver not found in PATH
DEBUG   chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
DEBUG   Using shell command to find out chrome version
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=115.0.5790.110\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: chrome 115.0.5790.110
DEBUG   Reading metadata from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
DEBUG   Required driver: chromedriver 115.0.5790.102
DEBUG   Driver URL: https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5790.102/win64/chromedriver-win64.zip
INFO    Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\115.0.5790.102\chromedriver.exe
INFO    Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

Not specifying browser version (second time, and so, the browser version is already stored in the local metadata, valid for 1 hour)

C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --browser chrome --debug
    Finished dev [unoptimized + debuginfo] target(s) in 0.24s
     Running `target\debug\selenium-manager.exe --browser chrome --debug`
DEBUG   Checking chromedriver in PATH
DEBUG   Running command: chromedriver --version
DEBUG   Output: ""
DEBUG   chromedriver not found in PATH
DEBUG   chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
DEBUG   Using shell command to find out chrome version
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=115.0.5790.110\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: chrome 115.0.5790.110
DEBUG   Required driver: chromedriver 115.0.5790.102
DEBUG   chromedriver 115.0.5790.102 already in the cache
INFO    Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\115.0.5790.102\chromedriver.exe
INFO    Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

Using stable for browser version (first time)

C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --browser chrome --debug --browser-version stable
    Finished dev [unoptimized + debuginfo] target(s) in 0.22s
     Running `target\debug\selenium-manager.exe --browser chrome --debug --browser-version stable`
DEBUG   Checking chromedriver in PATH
DEBUG   Running command: chromedriver --version
DEBUG   Output: ""
DEBUG   chromedriver not found in PATH
DEBUG   chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
DEBUG   Using shell command to find out chrome version
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=115.0.5790.110\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: chrome 115.0.5790.110
DEBUG   Reading metadata from https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json
DEBUG   Online stable chrome version (115) is the same as the one installed in the system
DEBUG   Required driver: chromedriver 115.0.5790.102
DEBUG   chromedriver 115.0.5790.102 already in the cache
INFO    Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\115.0.5790.102\chromedriver.exe
INFO    Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

Using stable for browser version (second time, and so, the browser version is already stored in the local metadata, valid for 1 hour)

C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --browser chrome --debug --browser-version stable
    Finished dev [unoptimized + debuginfo] target(s) in 0.22s
     Running `target\debug\selenium-manager.exe --browser chrome --debug --browser-version stable`
DEBUG   Checking chromedriver in PATH
DEBUG   Running command: chromedriver --version
DEBUG   Output: ""
DEBUG   chromedriver not found in PATH
DEBUG   chrome detected at C:\Program Files\Google\Chrome\Application\chrome.exe
DEBUG   Using shell command to find out chrome version
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=115.0.5790.110\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: chrome 115.0.5790.110
DEBUG   Online stable chrome version (115) is the same as the one installed in the system
DEBUG   Required driver: chromedriver 115.0.5790.102
DEBUG   chromedriver 115.0.5790.102 already in the cache
INFO    Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\115.0.5790.102\chromedriver.exe
INFO    Browser path: C:\Program Files\Google\Chrome\Application\chrome.exe

Copy link
Copy Markdown
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!

@bonigarcia bonigarcia merged commit c0317a5 into trunk Jul 31, 2023
@bonigarcia bonigarcia deleted the se_mgr_chrome_ttl branch July 31, 2023 08:18
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.

3 participants