Watir Timeout issue with Firefox - firefox

I am attempting to run the following ruby code via RubyMine:
require 'rubygems'
require 'watir-webdriver'
browser = Watir::Browser.new :firefox
browser.goto 'http://www.apple.com'
When I run I get the following error:
firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:55:in block in launch'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/socket_lock.rb:43:inlocked'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:51:in launch'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:43:ininitialize'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in new'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:infor'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in for'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/watir-webdriver-0.9.3/lib/watir-webdriver/browser.rb:46:ininitialize'
from /Users/mark/cheezy/first_script.rb:3:in new'
from /Users/mark/cheezy/first_script.rb:3:in'
from -e:1:in load'
from -e:1:in'
I have the latest Watir-Webdriver gem installed .
Any ideas please?
Thanks

For Firefox 48+ you need to use geckodriver.
Download from here: https://github.com/mozilla/geckodriver/releases
Selenium instructions: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
Watir instructions: http://watir.github.io/watir-6-beta/
Please let me know if you have any further issues.

Related

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

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

Getting browsermob/proxy (LoadError) in windows 7

I am trying to run Browsermob proxy tool using selenium cucumber with a ruby in windows 7 but am facing with browsermob/proxy (LoadError) while importing browsermob/proxy libriary. I installed all required gems. could someone help me with this issue
This is my code:
require 'browsermob/proxy'
require 'selenium-webdriver'
require 'rspec/expectations'
include RSpec::Matchers
This is the error message:
C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
require': cannot load such file -- browsermob/proxy (LoadError)
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_req
uire.rb:55:in 'require'
from bandwidth_limit.rb:3:in '<main>'
What can I do to fix this?
Install Browsermob proxy using gem install. give below command in command prompt
gem install browsermob-proxy

Uninitialized constant System (NameError) in Selenium with ruby

I am learning automation and have no prior programming knowledge. I am trying to learn Selenium with ruby: I am having issues with launching the firefox browser.What am i doing wrong?
My code is
require 'rubygems'
require 'selenium-webdriver'
System.setProperty("webdriver.gecko.driver","path of geckodriver.exe");
WebDriver = new FirefoxDriver();
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://facebook.com"
puts"facebook is loaded in FF browser"
I am getting the following error:
3:in '':uninitialized constant System (NameError)
Did you mean? SysytemExit

Selenium Webdriver Unable to create chrome webdriver instance

We've been running integration tests successfully against Rails 2 using Selenium on both chrome and firefox. However, we've recently upgraded to Rails 3 and are running into issues creating a chrome webdriver instance.
When we attempt to create, we get the following stack:
irb(main):002:0> profile = Selenium::WebDriver::Chrome::Profile.new
translate])#<Selenium::WebDriver::Chrome::Profile:0x64f2fd0 #extensions=[], #model=nil>
irb(main):003:0> profile['download.prompt_for_download'] = false
false
irb(main):004:0> driver = Selenium::WebDriver.for(:chrome, :profile => profile, :switches => %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate])
ArgumentError: wrong number of arguments (0 for 1)
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/platform.rb:157:in `open'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/platform.rb:157:in `ip'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/platform.rb:170:in `interfaces'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/port_prober.rb:23:in `free?'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/port_prober.rb:5:in `above'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/chrome/service.rb:33:in `default_service'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/chrome/bridge.rb:14:in `initialize'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/driver.rb:37:in `new'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/driver.rb:37:in `for'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver.rb:67:in `for'
from (irb):4
Any tips?
I saw this when I had included a gem which included the "backports" gem as part of its dependencies into my Gemfile. The backports gem rewrites some Ruby 1.8 internals, which overwrote parts of the UDPSocket core class. Try getting rid of the backports gem and giving it a shot.
ChromeDriver Installation:
Download Chromedriver 2.x from "http://chromedriver.storage.googleapis.com/index.html?path=2.8/." Unzip it and save it in a folder on any drive. Set path by following steps :
Copy the path till chromedriver.exe
Right click on Computer and select ‘Properties’
Select ‘Advanced system variables’
Select ‘Environment variables’
Click on Edit button for ‘Path’ variable of ‘User variables’
Append the chromedriver path
Save changes.
Run Selenium Test :
Now run your selenium test. It will run on the chrome browser.
Sample Code
require 'selenium-webdriver'
$driver = Selenium::WebDriver.for :chrome
$driver.navigate.to "https://www.google.co.in/"
$driver.manage().window().maximize()
$driver.quit()
NOTE : You need to install latest chromedriver for latest version of Chrome browser
This was caused by an interference with the backports gem and the fact that the socket library reuses IO.open although it changes the interface.
Upgrading backports to v2.6.7 or above should resolve this.

Missing gem watir?

ahmet#Ubuntu:~/test$ ruby hello.rb
/home/ahmet/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- watir (LoadError)
from /home/ahmet/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from hello.rb:2:in `<main>'
I have required rubygems in my .rb but still get this error
require 'rubygems'
require 'watir'
According to Watir Readme you have to install and require firewatir. Also you may want to install watir-webdriver instead.
I encountered a similar problem with a different gem a while back on Ubuntu using RVM. I know the gem was installed, because I had just installed it. I did the following:
rvm get latest
rvm reload
gem update --system
Then for good measure I reinstalled the gem, and everything worked. Hope this helps you as well.
Read this: https://github.com/zeljkofilipin/watirbook/blob/master/installation/ubuntu.md
The require should be either 'firewatir' or 'watir-webdriver'
require 'firewatir'
or
require 'watir-webdriver'

Resources