Skip to content

[rust] Include support for browser path in Selenium Manager (#11351)#11496

Merged
bonigarcia merged 3 commits intotrunkfrom
se_mgr_browser_path
Jan 9, 2023
Merged

[rust] Include support for browser path in Selenium Manager (#11351)#11496
bonigarcia merged 3 commits intotrunkfrom
se_mgr_browser_path

Conversation

@bonigarcia
Copy link
Copy Markdown
Member

Description

This PR adds the option --browser-path in Selenium Manager, which allows to specify the browser path for browser version detection. For instance:

> cargo run -- --debug --browser chrome --browser-path "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target\debug\selenium-manager.exe --debug --browser chrome --browser-path "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"`
DEBUG   Using shell command to find out chrome version
DEBUG   Running cmd command: "wmic datafile where name='C:\\\\Program Files\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe' get Version /value"
DEBUG   Output { status: ExitStatus(ExitStatus(0)), stdout: "\r\r\n\r\r\nVersion=108.0.5359.125\r\r\n\r\r\n\r\r\n\r\r\n", stderr: "" }
DEBUG   The version of chrome is 108.0.5359.125
DEBUG   Detected browser: chrome 108
DEBUG   Required driver: chromedriver 108.0.5359.71
DEBUG   chromedriver 108.0.5359.71 already in the cache
INFO    C:\Users\boni\.cache\selenium\chromedriver\win32\108.0.5359.71\chromedriver.exe

Motivation and Context

This PR implements #11351.

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.

@titusfortner
Copy link
Copy Markdown
Member

This is having issues parsing spaces on Mac:

sl-1495:macos titusfortner$ "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta" --version
Google Chrome 109.0.5414.61 beta
sl-1495:macos titusfortner$ ./selenium-manager --browser chrome --browser-path "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta" --debug
DEBUG	Using shell command to find out chrome version
DEBUG	Running sh command: "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta --version"
DEBUG	Output { status: ExitStatus(unix_wait_status(32512)), stdout: "", stderr: "sh: /Applications/Google: No such file or directory\n" }

Ideally should be able to support it with backslash escapes and no quotes as well:

sl-1495:macos titusfortner$ /Applications/Google\ Chrome\ Beta.app/Contents/MacOS/Google\ Chrome\ Beta --version
Google Chrome 109.0.5414.61 beta
sl-1495:macos titusfortner$ ./selenium-manager --browser chrome --browser-path /Applications/Google\ Chrome\ Beta.app/Contents/MacOS/Google\ Chrome\ Beta --debug
DEBUG	Using shell command to find out chrome version
DEBUG	Running sh command: "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta --version"
DEBUG	Output { status: ExitStatus(unix_wait_status(32512)), stdout: "", stderr: "sh: /Applications/Google: No such file or directory\n" }

@bonigarcia
Copy link
Copy Markdown
Member Author

When the path has spaces in Unix/Linux, it should be escaped using the \. Also in this case, we need to use " at the beginning and end of the path (to avoid splitting the command argument). All in all, the command should be as follows:

bonigarcia@SL-2030 rust % cargo run -- --browser chrome --debug --browser-path "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
    Finished dev [unoptimized + debuginfo] target(s) in 0.38s
     Running `target/debug/selenium-manager --browser chrome --debug --browser-path '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'`
DEBUG	Using shell command to find out chrome version
DEBUG	Running sh command: "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --version"
DEBUG	Output { status: ExitStatus(unix_wait_status(0)), stdout: "Google Chrome 108.0.5359.124 \n", stderr: "" }
DEBUG	The version of chrome is 108.0.5359.124
DEBUG	Detected browser: chrome 108
DEBUG	Reading chromedriver version from https://chromedriver.storage.googleapis.com/LATEST_RELEASE_108
DEBUG	starting new connection: https://chromedriver.storage.googleapis.com/
DEBUG	No cached session for DnsName(DnsName(DnsName("chromedriver.storage.googleapis.com")))
DEBUG	Not resuming any session
DEBUG	Using ciphersuite TLS13_AES_256_GCM_SHA384
DEBUG	Not resuming
DEBUG	TLS1.3 encrypted extensions: [Protocols([6832])]
DEBUG	ALPN protocol is Some(b"h2")
DEBUG	Ticket saved
DEBUG	Ticket saved
DEBUG	Sending warning alert CloseNotify
DEBUG	Required driver: chromedriver 108.0.5359.71
DEBUG	chromedriver 108.0.5359.71 already in the cache
INFO	/Users/bonigarcia/.cache/selenium/chromedriver/mac-arm64/108.0.5359.71/chromedriver

@titusfortner titusfortner mentioned this pull request Jan 7, 2023
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 7, 2023

Codecov Report

Base: 54.55% // Head: 54.55% // No change to project coverage 👍

Coverage data is based on head (be5ad0f) compared to base (8181483).
Patch has no changes to coverable lines.

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

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #11496   +/-   ##
=======================================
  Coverage   54.55%   54.55%           
=======================================
  Files          85       85           
  Lines        5629     5629           
  Branches      243      243           
=======================================
  Hits         3071     3071           
  Misses       2315     2315           
  Partials      243      243           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@bonigarcia bonigarcia merged commit 1f9e14e into trunk Jan 9, 2023
@bonigarcia bonigarcia deleted the se_mgr_browser_path branch January 9, 2023 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants