I am developing a Node.js app, and I use Selenium Webdriver on it for scraping purposes. However, when I deploy on Heroku, Selenium doesn't work. How can I make Selenium work on Heroku?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Selecting an item from a combo box selenium driver
- google-drive can't get push notifications
- Selenium in Java is not finding element when using
- How to specify memcache server to Rack::Session::M
I was able to get the Selenium Webdriver working on Node/Heroku using PhantomJs as the headless browser. I installed the PhantomJs buildpack to my Heroku app and it just worked. I struggled to get Chrome and Firefox drivers working on Heroku... I wrote a blog with the steps and code I used to get it working:
http://www.viderman.com/2017/05/selenium-on-heroku.html
Below is a javaScript sample code using selenium-webdriver npm package with chrome browser.
Before you are ready to deploy, you would need to add two buildpacks to Heroku.
or
Settings -> Add buildpacks -> https://github.com/heroku/heroku-buildpack-chromedriver -> Save changes
Settings -> Add buildpacks -> https://github.com/heroku/heroku-buildpack-google-chrome -> Save changes