Heroku: unable to connect to chromedriver 127.0.0.1:9515 when using Watir/Selenium

后端 未结 4 1670
难免孤独
难免孤独 2021-02-07 10:24

This runs locally (without specifying driver_path), but not on Heroku.

Code:

Selenium::WebDriver::Chrome.driver_path = ENV[         


        
4条回答
  •  伪装坚强ぢ
    2021-02-07 11:04

    I am quoting Ilya Vassilevsky from this post

    ChromeDriver is just a driver for Chrome. It needs the actual Chrome browser installed on the same machine to actually work.

    Heroku doesn't have Chrome installed on its dynos by default. You need to use a buildpack that installs Chrome. For example:

    https://github.com/dwayhs/heroku-buildpack-chrome

    You can see how it fetches Chrome:

    https://github.com/dwayhs/heroku-buildpack-chrome/blob/master/bin/compile#L36-38

    Then I read their discussion in the comments:

    Petr Gazarov says

    I tried this buildpack and it didn't work. I'm suspecting installing google chrome (or any browser) on heroku might be more involved.

    Ilya Vassilevsky replies

    Yes, Heroku is a very opinionated and closed platform. It should be much easier to set up Chrome with ChromeDriver on your own VM on AWS, Linode, or DigitalOcean.

    Petr Gazarov replies

    Thanks for your answer Ilya. I ended up re-writing with Watir with phantomjs because I couldn't get Heroku to install Chrome.

    You can read more info in that question. If something comes to my mind, I will post it.

提交回复
热议问题