3

I have been using watir-webdriver / MiniTest framework for just under a month now and it has been going really well. However the pack that I'm required to run every time a new build is launched contains just under 100 individual tests which takes well over an hour to go through all of them.

This is why I setup a VPS with Ruby, RVM, Watir, Rails and Firefox on a Centos-6-x86_64. This way I don't have to run the scripts on my laptop and wait for them to finish before I can do anything else.

However when I tried to test that watir was working using irb I get the following error:

 Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)

Test:

[root@V-9876 ~]# irb
1.9.3p448 :001 > require 'watir-webdriver'
 => true
1.9.3p448 :002 > b = Watir::Browser.start 'www.google.com'
Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/common/port_prober.rb:28:in `initialize'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/common/port_prober.rb:28:in `new'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/common/port_prober.rb:28:in `block in free?'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/common/port_prober.rb:26:in `each'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/common/port_prober.rb:26:in `free?'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/common/port_prober.rb:5:in `above'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/firefox/launcher.rb:49:in `find_free_port'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/firefox/launcher.rb:33:in `block in launch'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/    lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/firefox/bridge.rb:24:in `initialize'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/common/driver.rb:31:in `new'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/     lib/selenium/webdriver/common/driver.rb:31:in `for'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/      lib/selenium/webdriver.rb:67:in `for'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/watir-webdriver-0.6.4/lib/ watir-     webdriver/browser.rb:46:in `initialize'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/watir-webdriver-0.6.4/lib/ watir-    webdriver/browser.rb:29:in `new'
        from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/watir-webdriver-0.6.4/lib/ watir-     webdriver/browser.rb:29:in `start'
        from (irb):2
         from /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/irb:13:in `<main>'1.9.3p4     1.9.3p448 :003 >

I have been researching that error and I have found many sites that claim that it is fixed by disabling ipv6 which I did and I am still getting this error.

Not sure if this makes a difference but I also have NGinX / PHP / MySQL installed on this VPS

EDIT - The ruby file is posted below

require "watir-webdriver"
require 'watir-webdriver'
require 'headless'
headless = Headless.new
headless.start

browser = Watir::Browser.new :ff
browser.goto "http://remove-url-for-this-post.com" 
puts ("Starting SearchValSelectFields")
browser.select_list(:id, "edit-select-sector").select("Finance and Accounting")
sleep (5)
browser.select_list(:id, "edit-select-subsector--3").select("All Sub-sector")
browser.select_list(:id, "edit-select-location").select("Singapore")
browser.button(:value,"Search").click
assert(browser.text.include?("Salary and employment forecast"))
browser.screenshots ('..\screenshots\SearchValSelectFields.png')
browser.select_list(:id, "edit-select-sector").select("Select Sector")
sleep(3)
browser.select_list(:id, "edit-select-subsector--2").select("Select Sub-sector")
sleep(3)
browser.select_list(:id, "edit-select-location").select("Select Location")
sleep(3)
browser.button(:value,"Search").click
assert(browser.text.include?("This field is required"))
browser.close
headless.destroy

Any ideas?

Holger Just
  • 52,918
  • 14
  • 115
  • 123
CustomNet
  • 732
  • 3
  • 12
  • 31
  • so you wan't to launch firefox on your vps? is that supposed to run headless? – phoet Nov 09 '13 at 14:28
  • I followed a guide to install firefox on the VPS and that's just to begin with to show it works. I'd actually like Chrome and IE to be run. And yes this would have to be headless. – CustomNet Nov 09 '13 at 15:26

1 Answers1

7

Somebody at work managed to fix the issue. He said:

They try to connect twice
first to 127.0.0.1 port 7055
then too ::1 port 7055
second one fails
::1 is localhost of IPv6
so you seem to be connecting localhost
and in your server look at /etc/hosts
localhost resolves to the ::1

So all you have to do is edit your /etc/hosts file and comment out ::1 or remove it if you want

CustomNet
  • 732
  • 3
  • 12
  • 31