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

Can we have a WD_CHROME_PATH ENV variable that sets chrome binary path? #137

Closed
tchia04 opened this issue Jun 14, 2019 · 9 comments · Fixed by #138
Closed

Can we have a WD_CHROME_PATH ENV variable that sets chrome binary path? #137

tchia04 opened this issue Jun 14, 2019 · 9 comments · Fixed by #138
Assignees

Comments

@tchia04
Copy link

tchia04 commented Jun 14, 2019

Summary

Set Selenium::WebDriver::Chrome.path to ENV['WD_CHROME_PATH'] if it's defined.
This is similar to the WD_INSTALL_DIR env var for Webdrivers.install_dir

Debug Info

Please provide the following information for bug reports:

  • Operating system / CI Environment:
  • Browser and version:

Expected Behavior

If WD_CHROME_PATH is defined, then use that for Selenium::WebDriver::Chrome.path
Otherwise, use the default location.

Actual Behavior

Currently I have to muck around my spec_helper.rb but it would be nice to have this as part of webdriver itself to be consistent with WD_INSTALL_DIR

@kapoorlakshya
Copy link
Collaborator

Yeah, I was planning to do that. Will work on it this weekend.

@kapoorlakshya
Copy link
Collaborator

@tchia04 Can you please load this gem from the master branch and confirm WD_CHROME_PATH works for you? Thanks!

# In Gemfile

gem 'webdrivers', git: 'https://github.com/titusfortner/webdrivers.git', branch: 'master'

@tchia04
Copy link
Author

tchia04 commented Jun 24, 2019

Hi @kapoorlakshya
WD_CHROME_PATH works fine for me on Mac.
However it doesn't work for me on Ubuntu.

My test setup
On my the linux my default system chrome version is 69 and I installed a new chrome version(v74) to a local folder and point the WD_CHROME_PATH to it.

However when I ran it without the special handling from below, I got

========

An error occurred in an after hook
Selenium::WebDriver::Error::SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 74


because It tried to use chrome74 with chromedriver2.41 (which is the compatible with system default chrome version of 69)

Once I force WD_CHROME_PATH env to Selenium::WebDriver::Chrome.path then the webdriver sesssion got created successfully because the chrome and chromedriver version matches.

case RUBY_PLATFORM
  when /darwin/i
    Webdrivers.logger.info('Running under Mac. No special handling required')
  when /linux/i
    # is this a webdriver issue?
    Webdrivers.logger.info('Running under Linux. Need special handling since under Ubuntu it seems to ignore the WD_CHROME_PATH')
    Selenium::WebDriver::Chrome.path = ENV['WD_CHROME_PATH'] if ENV['WD_CHROME_PATH']
  else
    put "invalid os platform"
end

I am testing with

  remote: https://github.com/titusfortner/webdrivers.git
  revision: 0e754604fe8760569f413dd4403eb4c90b837254
  branch: master
  specs:
    webdrivers (4.0.1)
      nokogiri (~> 1.6)
      rubyzip (~> 1.0)
      selenium-webdriver (>= 3.0, < 4.0)

@kapoorlakshya
Copy link
Collaborator

kapoorlakshya commented Jun 24, 2019

I think the problem is that webdrivers is correctly downloading chromedriver v74 to match the browser binary version defined via the ENV variable, but Selenium (driver) itself is launching v69 from the default location.

You'll need Selenium::WebDriver::Chrome.path = ENV['WD_CHROME_PATH'] if ENV['WD_CHROME_PATH'] to make sure Selenium launches Chrome v74.

Edit: webdrivers is working as expected. You just need to make sure both Selenium and webdrivers are using the same browser path.

@tchia04
Copy link
Author

tchia04 commented Jun 25, 2019

Ok. I though the webdriver is a layer on top of Selenium so I don't have do deal with the Selenium configurations. Actually I found that Mac is not working when I tries to use chrome 76 so both Mac and Linux needs

    Selenium::WebDriver::Chrome.path = ENV['WD_CHROME_PATH'] if ENV['WD_CHROME_PATH']

@twalpole
Copy link
Collaborator

twalpole commented Jun 25, 2019

WebDrivers was originally designed to manage getting the correct version of the driver to match the browser you're using. It wasn't designed to manage configuring the browser.

@kapoorlakshya
Copy link
Collaborator

And since chromedriver v76 is still in beta, you'll need to specifically require it as described here.

@tchia04
Copy link
Author

tchia04 commented Jun 25, 2019

Ok. Thanks for the explantion @twalpole @kapoorlakshya
Can you make a new release so I don't have to pin to the master branch in my Gemfile?

@kapoorlakshya
Copy link
Collaborator

@tchia04 Just released v4.1.0.

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

Successfully merging a pull request may close this issue.

3 participants