Capybara, Selenium, headless Chrome, Ubuntu Net::ReadTimeout -


i saw similar question mine. works fine on os x, throws errors on ubuntu 14.04. retracing post, getting same error. original poster gave , used poltergeist / phantomjs instead. i'd make work chrome phantomjs no longer being maintained.

net::readtimeout: net::readtimeout , selenium::webdriver::error::unknownerror: unknown error: chrome failed start on rails 5.1.beta system test

here install steps on ubuntu:

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976eaf437d05b5 wget -q -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -  cat <<eof > /etc/apt/sources.list.d/google-chrome.list deb http://dl.google.com/linux/chrome/deb/ stable main eof apt-get update apt-get install --force-yes -y google-chrome-stable cd /root/ && curl -o "http://chromedriver.storage.googleapis.com/2.32/chromedriver_linux64.zip" cd /root/ && unzip chromedriver_linux64.zip && cp chromedriver /usr/bin 

taking 1 step @ time, confirmed google-chrome, chromedriver installed correctly , work fine. selenium driver works fine.

link = env['link'] || "https://www.amazon.com" #https://stackoverflow.com/questions/44424200/how-do-i-use-selenium-webdriver-on-headless-chrome selenium::webdriver::chrome.driver_path="/usr/bin/chromedriver" if ruby_platform.include? "linux" options = %w[--headless --disable-gpu] options +=  %w[--binary='/usr/bin/google-chrome'] if ruby_platform.include? "linux" driver = selenium::webdriver.for :chrome, switches: options driver.navigate.to "#{link}" driver.save_screenshot("./screen.png") driver.quit 

the capybara test times out while visiting url.

require 'capybara' include capybara::dsl  link = env['link'] || "https://www.amazon.com" options = %w[--headless --disable-gpu] options +=  %w[--binary='/usr/bin/google-chrome'] if ruby_platform.include? "linux" selenium::webdriver::chrome.driver_path="/usr/bin/chromedriver" if ruby_platform.include? "linux" capybara.register_driver(:headless_chrome) |app|     capabilities = selenium::webdriver::remote::capabilities.chrome( chromeoptions: { args: options } )     capybara::selenium::driver.new(app, browser: :chrome, desired_capabilities: capabilities ) end capybara.javascript_driver = :headless_chrome session = capybara::session.new(:headless_chrome) session.visit "#{link}" 

the error following msg:

session.visit "#{link}"

net::readtimeout: net::readtimeout     /usr/lib/ruby/2.3.0/net/protocol.rb:158:in `rbuf_fill'     /usr/lib/ruby/2.3.0/net/protocol.rb:136:in `readuntil'     /usr/lib/ruby/2.3.0/net/protocol.rb:146:in `readline'     /usr/lib/ruby/2.3.0/net/http/response.rb:40:in `read_status_line'     /usr/lib/ruby/2.3.0/net/http/response.rb:29:in `read_new'     /usr/lib/ruby/2.3.0/net/http.rb:1437:in `block in transport_request'     /usr/lib/ruby/2.3.0/net/http.rb:1434:in `catch'     /usr/lib/ruby/2.3.0/net/http.rb:1434:in `transport_request'     /usr/lib/ruby/2.3.0/net/http.rb:1407:in `request'     /usr/lib/ruby/2.3.0/net/http.rb:1400:in `block in request'     /usr/lib/ruby/2.3.0/net/http.rb:853:in `start'     /usr/lib/ruby/2.3.0/net/http.rb:1398:in `request'     /var/www/railsapp/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:107:in `response_for'     /var/www/railsapp/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:58:in `request'     /var/www/railsapp/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:59:in `call'     /var/www/railsapp/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:649:in `raw_execute' ... 10 levels...     /usr/bin/irb:11:in `<top (required)>'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `load'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `kernel_load'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:27:in `run'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:332:in `exec'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:20:in `dispatch'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:11:in `start'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle:34:in `block in <top (required)>'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'     /usr/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle:26:in `<top (required)>'     /usr/bin/bundle:23:in `load'     /usr/bin/bundle:23:in `<main>' 

headless chrome , chromedriver support relatively new. update selenium-webdriver latest versions (3.5.2 of answer) have support it. once you've done that, if you're using latest capybara, can try using capybara provided registered driver,

if ruby_platform.include? "linux"   selenium::webdriver::chrome.driver_path = "/usr/bin/chromedriver"   selenium::webdriver::chrome.path = "/usr/bin/google-chrome" end capybara.javascript_driver = :selenium_chrome_headless 

rather needing register own driver.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -