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

add support for heroku/heroku-buildpack-google-chrome #40

Closed
wants to merge 1 commit into from
Closed

add support for heroku/heroku-buildpack-google-chrome #40

wants to merge 1 commit into from

Conversation

beauraF
Copy link

@beauraF beauraF commented Mar 25, 2019

Hi,

On heroku CI, with heroku/heroku-buildpack-google-chrome, webdrivers having some issues.

Heroku replaces the google-chrome command with the following script:

exec $HOME/.apt/opt/google/chrome/chrome --headless --no-sandbox --disable-gpu --remote-debugging-port=9222 $@

This script does not support the --version option. In fact, when you make a call to:

def chrome_on_linux
  `google-chrome --version`
end

Instead of getting the version, the script runs Google Chrome headlessly in forground.

I propose to add the support of this buildpack by checking the presence of the shims provided for this purpose by heroku. : https://github.com/heroku/heroku-buildpack-google-chrome#shims-and-command-line-flags

@kapoorlakshya
Copy link
Collaborator

Hi @beauraF, thanks for the PR. Are you using Selenium with heroku-buildpack-google-chrome?

You're right about --version launching the browser in the foreground. It should be --product-version. I've fixed it in #39 along with support for custom browser executable path or shims when using Selenium.

@beauraF
Copy link
Author

beauraF commented Mar 25, 2019

Hi @kapoorlakshya, thanks for ur answer.

Yes, we are using heroku-buildpack-google-chrome on Heroku CI with selenium-webdriver.
I tried ur fix on our CI and unfortunately it doesn't work. Same issue.

@kapoorlakshya
Copy link
Collaborator

kapoorlakshya commented Mar 25, 2019

Ah okay. Sorry, I'm not too familiar with Heroku, so let me ask you this -

  1. Is it possible to set Selenium::WebDriver::Chrome.path to the actual google-chrome binary that the
    shim wraps around?
  2. Does which google-chrome return $HOME/.apt/opt/google/chrome/chrome or /usr/bin/google-chrome?
  3. Which path does ENV['GOOGLE_CHROME_BIN'] point to?

Just checking to see if we can make this work with the current code in #39. If we cannot, I'd be happy to implement support for this.

@beauraF
Copy link
Author

beauraF commented Mar 26, 2019

No problem. :)

Is it possible to set Selenium::WebDriver::Chrome.path to the actual google-chrome binary that the shim wraps around?

I'm trying to find a suitable way to do it with our current stack.

Does which google-chrome return $HOME/.apt/opt/google/chrome/chrome or /usr/bin/google-chrome?

~ $ which google-chrome
/app/.apt/usr/bin/google-chrome

Which path does ENV['GOOGLE_CHROME_BIN'] point to?

~ $ echo $GOOGLE_CHROME_BIN
/app/.apt/opt/google/chrome/chrome

@beauraF
Copy link
Author

beauraF commented Mar 26, 2019

It's okay. By using #39 and setting Selenium::WebDriver::Chrome.path, everything is green.
I close this PR. Thank u @kapoorlakshya.

Just, do you know the difference between Selenium::WebDriver::Chrome.path and Selenium::WebDriver::Chrome::Options.binary ?

@beauraF beauraF closed this Mar 26, 2019
@kapoorlakshya
Copy link
Collaborator

Hi @beauraF, I'm glad it works for you now.

Just, do you know the difference between Selenium::WebDriver::Chrome.path and Selenium::WebDriver::Chrome::Options.binary ?

It sounds like they technically do the same thing - allow us to set path to the chrome binary. I found some info on binary here - http://chromedriver.chromium.org/capabilities. See the the chromeOptions section.

@titusfortner - Any insight on this?

@titusfortner
Copy link
Owner

Selenium::WebDriver::Chrome.path only applies locally. What gets passed in to the Options is supposed to work both locally and remotely.

The current Selenium code is actually setting Selenium::WebDriver::Chrome::Options.binary to Selenium::WebDriver::Chrome.path if it is specified. This is "wrong" because it will cause problems when executing on a remote server. We're still trying to hammer out the right way to fix it.

jabrown85 pushed a commit to heroku/heroku-buildpack-google-chrome that referenced this pull request Jun 21, 2019
)

This change adds out-of-the-box compatibility with the webdrivers gem, which apparently quite a few Heroku users are using. Currently, the users have to use a workaround in their project to get the Chrome version from $GOOGLE_CHROME_BIN, so that webdrivers can download the appropriate version of chromedriver, and then switch back to $GOOGLE_CHROME_SHIM to launch Chrome.

See titusfortner/webdrivers#40, titusfortner/webdrivers#72, and titusfortner/webdrivers#134.

This simple change will provide the convenience of not needing any hacks to make the two work :).
@kapoorlakshya
Copy link
Collaborator

The latest version of the google-chrome buildpack no longer needs the workaround described here. We've updated the SHIM to support webdrivers. See heroku/heroku-buildpack-google-chrome#73 for more information.

@beauraF
Copy link
Author

beauraF commented Jun 25, 2019

Insane. Thank you very much @kapoorlakshya !

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