titusfortner / webdrivers

Keep your Selenium WebDrivers updated automatically
MIT License
593 stars 111 forks source link

Webdriver Chrome Path #177

Closed muhammedtufekyapan closed 4 years ago

muhammedtufekyapan commented 4 years ago

Hi everyone,

I try to use webdrivers on Heroku. My local tests are great but it does not work on Heroku.

Lastly I add;

Selenium::WebDriver::Chrome.path = ENV['GOOGLE_CHROME_SHIM'] if ENV['GOOGLE_CHROME_SHIM'].present? driver = Selenium::WebDriver.for :chrome

before my task code.

When I run;

heroku run which google-chrome

I got

/app/.apt/usr/bin/google-chrome

Based on this I define GOOGLE_CHROME_SHIM = /app/.apt/usr/bin/google-chrome

After this When I try to push project I got error like this;

remote: ! Selenium::WebDriver::Error::WebDriverError: not a file: "/app/.apt/usr/bin/google-chrome"

How can I fix this?

jorbs commented 4 years ago

Hi,

Were you able to fix this error?

kapoorlakshya commented 4 years ago

@muhammedtufekyapan @jorbs Are you using heroku-buildpack-google-chrome? If yes, then please take a look at the instructions here: https://github.com/titusfortner/webdrivers/wiki/Heroku-buildpack-google-chrome

kapoorlakshya commented 4 years ago

And also make sure heroku-buildpack-chromedriver is not installed.

jorbs commented 4 years ago

@kapoorlakshya thank you for your response. Yes, I am using heroku-buildpack-google-chrome and removed the chromedriver buildpack from my app.json. It happens that I am still getting

Selenium::WebDriver::Error::WebDriverError: not a file: "/app/.apt/usr/bin/google-chrome-stable"
jorbs commented 4 years ago

More info: I have ssh'ed my Heroku test env and noticed that:

~ $ ls -la /app/.apt/usr/bin/google-chrome-stable
lrwxrwxrwx 1 u34628 dyno 32 Jun 19 20:12 /app/.apt/usr/bin/google-chrome-stable -> /opt/google/chrome/google-chrome
~ $ ls -la /opt/google/chrome/google-chrome
ls: cannot access '/opt/google/chrome/google-chrome': No such file or directory

The GOOGLE_CHROME_SHIM var points to a link and so that points to a invalid file.

kapoorlakshya commented 4 years ago

Hmm... that's strange. This is where that ENV var magic is happening: https://github.com/heroku/heroku-buildpack-google-chrome/blob/master/bin/compile#L191-L192

And just to confirm, you're getting the not a file error even with only having this line before launching the browser:

Selenium::WebDriver::Chrome.path = ENV['GOOGLE_CHROME_SHIM'] if ENV['GOOGLE_CHROME_SHIM'].present?

Right?

I don't have a Heroku CI account to troubleshoot this myself, so I am going to have to rely on you to assist me with debugging this.

jorbs commented 4 years ago

@kapoorlakshya Yes. But luckly I addessed the issue. I added buildpacks in the test env as well and it worked!

kapoorlakshya commented 4 years ago

@jorbs oh good! Can you share what exactly you did? We can add it to the Wiki to help out others, and then close this issue.

jorbs commented 4 years ago

First off, the Heroku google chrome buildpack works fine in my production app.

The not a file error was happening in the test environment because the buildpacks configuration was only in the root of my app.json. So I decided to include it in the "test" env as well and the error gone. Here is a piece of my app.json:

{
  "buildpacks": [
    ...
    {
      "url": "heroku/ruby"
    },
    {
      "url": "https://github.com/heroku/heroku-buildpack-google-chrome"
    }
  ],
  "env": { ... },
  "environments": {
    "test": {
      "buildpacks": [
        {
          "url": "heroku/nodejs"
        },
        {
          "url": "heroku/ruby"
        },
        {
          "url": "https://github.com/heroku/heroku-buildpack-google-chrome"
        }
      ],
      ...
  }
 }

Let me know it is clear.

kapoorlakshya commented 4 years ago

@jorbs Thank you!

@muhammedtufekyapan Can you try what @jorbs has shared above? I would like to close this issue if we don't need to troubleshoot this any further.

kapoorlakshya commented 4 years ago

Closing this due to lack of response + we have a solution. Feel free to revive this if needed.