Chrome Headless - Net::ReadTimeout: Net::ReadTimeout - ruby

I'm using Window and I want to use the Chrome Headless with Watir Automation. I have the following code in my Hooks file but when I run the script I'm getting the error message below:
Before do
#browser = Watir::Browser.new :chrome, headless: true
#browser.goto "www.somewebsite.com"
end
Error Message: Net::ReadTimeout: Net::ReadTimeout
I have downloaded the latest ChromeDriver v2.34 and the browser v63.
See my Gemfile here:https://gist.github.com/anonymous/0b526bf12ce744fedf38b0cca38693e0

Related

How to pass Chrome options in webdriver-user-agent gem for watir

I am trying to pass cookies option for Chrome Drive using Watir gem
From Watir documentation i can do Watir::Browser.new :chrome, opts
So for cookies I can do:
browser = Watir::Browser.new :chrome, options: {args: ['--user-data-dir=/cookies']}
When using the webdriver-user-agent gem for mobile testing, their documentation tells me to start the browser like this:
driver = Webdriver::UserAgent.driver(browser: :chrome, agent: :iphone)
browser = Watir::Browser.new driver
But now I don't know how I can pass the option for the Chrome

How can I run selenium-webdriver script written in Ruby in headless mode on digital-ocean droplet?

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!
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

Firefox with Capybara and Selenium-Webdriver

I'm using Cucumber with Capybara and Selenium-Webdriver. Until now, I've always used Chrome but the project has requested some cross browser tests for Firefox too.
When running in Firefox, I just get a blank window and webpage doesn't appear.
This is the error I get:
Selenium::WebDriver::Error::WebDriverError: no sessionId in returned payload
My setup is:
Firefox V54
Cucumber 2.4
Selenium-webdriver 3.4.0
geckodriver 0.17
My firefox profile:
if ENV['firefox']
Capybara.default_driver = :selenium
Capybara.register_driver :selenium do |app|
options = {
:js_errors => false,
}
Capybara::Selenium::Driver.new(app, :browser => :firefox)
end
Any ideas why I only get a blank window when Firefox starts up in the test?
You claim to be running geckodriver v0.17 (which should work with the other versions you list) however that error would imply you're not. Try running bundle exec geckodriver --version and seeing what it returns. I'm guessing you've got a gem installed that attempts to manage the download of geckodriver and an older version is actually being used when you run your tests. If that is the case check with the specific gem documentation on how to update the installed geckodriver.

unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) -CentOS

I get the error: unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) when I run this code:
require 'watir-webdriver'
require 'headless'
headless = Headless.new
headless.start
begin
browser = Watir::Browser.start "https://google.com"
rescue Exception => e
puts e
puts "Exiting..."
exit
end
browser.goto "http://google.com"
puts browser.url
browser.close
I am using: I am using Firefox version 38.7.0, Headless gem version 2.2.3 and Selenium-Webdriver gem version 2.53.0.
I have tried:
Updating selenium-webdriver
Uninstalling headless, selenium and Firefox and reinstalling
them.
Restarting the server
Updating Firefox to 45.0
The same code works fine in other test environments.
Updates:
I have tried running the same code with Chrome as suggested by a poster. I got the error message: unable to connect to chromedriver 127.0.0.1:9515
Just to be sure everything is installed right I just ran the following:
yum install xorg-x11-server-Xvfb
Response:
Package xorg-x11-server-Xvfb-1.15.0-36.el6.centos.x86_64 already installed and latest version
Nothing to do
I also ran:
yum install firefox
Response:
Package firefox-38.7.0-1.el6.centos.x86_64 already installed and latest version
Nothing to do
So it turns out that it was a user rights issue that was causing the problem. I logged in as the root user and was pleasantly surprised to see that the code ran without any errors.

Why does this not work on IE9 but works on Firefox?

I am trying to run webdriver tests on IE. My script works on Firefox but not on IE9. I am using selenium-webdriver version 2.5.0 with ruby 1.8.7 patch level 352
Here is my ruby script:
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :ie
driver.navigate.to "http://www.gapinc.com/"
element = driver.find_element(:name, 'search')
element.send_keys 'Employees'
element.submit
puts driver.title
driver.quit
On IE9, I get Unable to find element with name == search (Selenium::WebDriver::Error::NoSuchElementError) and it passes on Firefox
It may be sync issue. Did you try using ImplicitlyWait or WebDriverWait?

Resources