运维开发网

ruby-on-rails – Watir-Webdriver – 协议不支持的地址族 – socket(2)

运维开发网 https://www.qedev.com 2020-08-05 19:19 出处:网络 作者:运维开发网整理
我一直在使用watir-webdriver / MiniTest框架不到一个月,而且一直都很顺利.然而,每次启动新构建时我需要运行的包包含不到100个单独的测试,这需要花费一个多小时来完成所有这些测试. 这就是我在Centos-6-x86_64上使用Ruby,RVM,Watir,Rails和Firefox设置VPS的原因.这样我就不必在我的笔记本电脑上运行脚本并等待它们完成,然后才能做其他事情.
我一直在使用watir-webdriver / MiniTest框架不到一个月,而且一直都很顺利.然而,每次启动新构建时我需要运行的包包含不到100个单独的测试,这需要花费一个多小时来完成所有这些测试.

这就是我在Centos-6-x86_64上使用Ruby,RVM,Watir,Rails和Firefox设置VPS的原因.这样我就不必在我的笔记本电脑上运行脚本并等待它们完成,然后才能做其他事情.

但是,当我试图测试watir使用irb工作时,我收到以下错误:

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

测试:

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

我一直在研究这个错误,我发现许多网站声称它是通过禁用ipv6修复的,我做了,我仍然得到这个错误.

不确定这是否有所不同,但我也在这个VPS上安装了NGinX / PHP / MySQL

编辑 – ruby文件发布在下面

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

有任何想法吗?

工作的人设法解决了这个问题.他说:

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

所以你要做的就是编辑你的/ etc / hosts文件并注释掉:: 1或者你想要删除它

0

精彩评论

暂无评论...
验证码 换一张
取 消