0
votes

I can not run ruby scripts on digital-ocean droplet. I tried running with selenium-webdriver and watir gems, but doesn't work.

I tried running with different versions of chromedriver, changed also selenium-webdriver's gem versions, but didn't work. My ruby -v: ruby 2.3.1p112 selenium-webdriver -v: (3.141.0) Chromedriver -v: 2.46

require 'selenium-webdriver'

options = Selenium::WebDriver::Chrome::Options.new(args: ['start-maximized','disable-gpu', 'no-sandbox', 'disable-setuid-sandbox', 'disable-dable-dev-shm-usage'], binary: ('/bin/chromedriver')) options.headless!

driver = Selenium::WebDriver.for(:chrome, options: options)

Error I get: /usr/share/rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.141.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok': unknown error: Chrome failed to start: exited abnormally (Selenium::WebDriver::Error::UnknownError) unknown error: DevToolsActivePort file doesn't exist)

Thanks for attention!

1

1 Answers

1
votes

This is how I get Chrome to run in headless mode:

options = Selenium::WebDriver::Chrome::Options.new(args: ['headless'])
driver = Selenium::WebDriver.for :chrome, options: options

You are passing some of the args through incorrectly, headless mode should be included. You also shouldn't need binary: ('/bin/chromedriver') if your chromedriver.exe is added to your PATH correctly.

So for your above example, the following should work:

    options = Selenium::WebDriver::Chrome::Options.new(args: ['headless', 
    'start-maximized','disable-gpu', 'no-sandbox', 'disable-setuid-sandbox', 
    'disable-dable-dev-shm-usage'])
     driver = Selenium::WebDriver.for :chrome, options: options

Hope this helps, Dan