只需一个简单的脚本来自动化Firefox浏览器: 只需一个简单的脚本来自动化Firefox浏览器:
require 'rubygems'
require 'watir-webdriver'
# Initialize watir firefox browser
$browser = Watir::Browser.new :ff , :profile => 'default'
导致以下错误,我无法弄清楚。是否有TCP端口被阻止或什么?。我正在使用我的办公室电脑顺便说一句,代码在我的家用电脑上工作正常。
C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `initialize': getaddrinfo: No such
host is known. (SocketError)
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `open'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `connect'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:744:in `start'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver/remote/http/default.rb:76:in `response_for'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver/remote/http/default.rb:38:in `request'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver/remote/http/common.rb:40:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver/remote/bridge.rb:598:in `raw_execute'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver/remote/bridge.rb:92:in `create_session'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver/remote/bridge.rb:68:in `initialize'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver/firefox/bridge.rb:28:in `initialize'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver/common/driver.rb:31:in `new'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver/common/driver.rb:31:in `for'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.22.2/lib/s
elenium/webdriver.rb:65:in `for'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir
-webdriver/browser.rb:35:in `initialize'
from sic_class.rb:8:in `new'
from sic_class.rb:8:in `<main>'
没有代理,我使用的是Windows 7,watir webdriver 0.6.1和firefox 13.01
答案 0 :(得分:0)
如果要安装gem,则必须在ur PATH中设置http_proxy环境变量。但是这会导致watir-webdriver的上述问题,在删除http_proxy变量后它对我有用。然后它使用浏览器中的代理设置。