Skip to content

Conversation

bonigarcia
Copy link
Member

Description

So far, Selenium Manager is very sensitive to using back-slash symbols in Windows paths. This happens since the command to discover the browser version in Windows internally uses WMIC, which has some very restrictive behavior regarding paths.

For instance, if the user specifies a browser path in Windows, it must be double-quoted. Otherwise, the command for browser version discovery does not work correctly. For example

C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --browser firefox --debug --browser-path "C:\Program Files\Mozilla Firefox\firefox.exe"
   Compiling selenium-manager v1.0.0-M3 (C:\Users\boni\Documents\dev\selenium\rust)
    Finished dev [unoptimized + debuginfo] target(s) in 2.53s
     Running `target\debug\selenium-manager.exe --browser firefox --debug --browser-path "C:\Program Files\Mozilla Firefox/firefox.exe"`
DEBUG   Running command: "geckodriver --version"
DEBUG   Output: ""
DEBUG   Using shell command to find out firefox version
DEBUG   Running command: "wmic datafile where name='C:\\Program Files\\Mozilla Firefox/firefox.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\n\r"
WARN    The version of firefox cannot be detected. Trying with latest driver version
DEBUG   Required driver: geckodriver 0.33.0
DEBUG   geckodriver 0.33.0 already in the cache
INFO    C:\Users\boni\.cache\selenium\geckodriver\win64\0.33.0\geckodriver.exe
C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --browser firefox --debug --browser-path "C:\\Program Files\\Mozilla Firefox\\firefox.exe"
    Finished dev [unoptimized + debuginfo] target(s) in 0.23s
     Running `target\debug\selenium-manager.exe --browser firefox --debug --browser-path "C:\\Program Files\\Mozilla Firefox\\firefox.exe"`
DEBUG   Running command: "geckodriver --version"
DEBUG   Output: ""
DEBUG   Using shell command to find out firefox version
DEBUG   Running command: "wmic datafile where name='C:\\\\Program Files\\\\Mozilla Firefox\\\\firefox.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\nVersion=115.0.0.8569\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: firefox 115.0.0.8569
DEBUG   Required driver: geckodriver 0.33.0
DEBUG   geckodriver 0.33.0 already in the cache
INFO    C:\Users\boni\.cache\selenium\geckodriver\win64\0.33.0\geckodriver.exe

This PR enhances the user experience regarding browser paths. In other words, this PR allows using single quotes in Windows for browser paths, as follows:

C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --browser firefox --debug --browser-path "C:\Program Files\Mozilla Firefox\firefox.exe"
   Compiling selenium-manager v1.0.0-M3 (C:\Users\boni\Documents\dev\selenium\rust)
    Finished dev [unoptimized + debuginfo] target(s) in 3.36s
     Running `target\debug\selenium-manager.exe --browser firefox --debug --browser-path "C:\Program Files\Mozilla Firefox\firefox.exe"`
DEBUG   Running command: "geckodriver --version"
DEBUG   Output: ""
DEBUG   Using shell command to find out firefox version
DEBUG   Running command: "wmic datafile where name='C:\\\\Program Files\\\\Mozilla Firefox\\\\firefox.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\nVersion=115.0.0.8569\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: firefox 115.0.0.8569
DEBUG   Required driver: geckodriver 0.33.0
DEBUG   geckodriver 0.33.0 already in the cache
INFO    C:\Users\boni\.cache\selenium\geckodriver\win64\0.33.0\geckodriver.exe
C:\Users\boni\Documents\dev\selenium\rust>cargo run -- --browser firefox --debug --browser-path "C:/Program Files/Mozilla Firefox/firefox.exe"
    Finished dev [unoptimized + debuginfo] target(s) in 0.22s
     Running `target\debug\selenium-manager.exe --browser firefox --debug --browser-path "C:/Program Files/Mozilla Firefox/firefox.exe"`
DEBUG   Running command: "geckodriver --version"
DEBUG   Output: ""
DEBUG   Using shell command to find out firefox version
DEBUG   Running command: "wmic datafile where name='C:\\\\Program Files\\\\Mozilla Firefox\\\\firefox.exe' get Version /value"
DEBUG   Output: "\r\r\n\r\r\nVersion=115.0.0.8569\r\r\n\r\r\n\r\r\n\r"
DEBUG   Detected browser: firefox 115.0.0.8569
DEBUG   Required driver: geckodriver 0.33.0
DEBUG   geckodriver 0.33.0 already in the cache
INFO    C:\Users\boni\.cache\selenium\geckodriver\win64\0.33.0\geckodriver.exe

Motivation and Context

This PR will allow us to prevent issues like #12300.

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 3, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jul 3, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (50f9252) 56.92% compared to head (822778b) 56.92%.

❗ Current head 822778b differs from pull request most recent head 23d2ca1. Consider uploading reports for the commit 23d2ca1 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   #12304   +/-   ##
=======================================
  Coverage   56.92%   56.92%           
=======================================
  Files          86       86           
  Lines        5423     5423           
  Branches      193      193           
=======================================
  Hits         3087     3087           
  Misses       2143     2143           
  Partials      193      193           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bonigarcia bonigarcia force-pushed the se_mgr_browser_path branch from ce9e64e to 23d2ca1 Compare July 3, 2023 13:15
@bonigarcia bonigarcia requested a review from diemol July 7, 2023 08:29
@titusfortner titusfortner merged commit 3887639 into trunk Jul 13, 2023
@titusfortner titusfortner deleted the se_mgr_browser_path branch July 13, 2023 15:26
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