Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Watir-Webdriver - Address family not supported by protocol - socket(2)

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?

like image 843
CustomNet Avatar asked Jan 30 '26 11:01

CustomNet


1 Answers

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

like image 144
CustomNet Avatar answered Feb 01 '26 01:02

CustomNet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!