更新:Watir webdriver Errno :: ECONNREFUSED:由於目標機器主動拒絕,無法建立連接。 - (2)連接
我運行下面的代碼來執行我的樣本測試案例:(Windows 7中的Watir 3.0.0,的Watir-的webdriver-0.6.1)
require "watir-webdriver"
require 'test/unit'
class Teste1
$var = Watir::Browser.new :chrome
def met1
$var.goto 'google.com'
$var.text_field(:name, "q").set 'sample'
$var.button(:name =>'btnG').click
end
end
class Teste2 < Test::Unit::TestCase
$test = Teste1.new
def test_gomet1
$test.met1()
end
end
瀏覽器打開,但腳本引發以下錯誤:
test_gomet1(Teste2):
Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:82:in `response_for'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:38:in `request'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:576:in `execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:99:in `get'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/navigation.rb:14:in `to'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:63:in `goto'
maisum.rb:11:in `met1'
maisum.rb:21:in `test_gomet1'
誰能幫助我嗎?
我建議你嘗試的代碼幾行儘可能重現該問題。 – 2012-07-21 11:11:39
刪除'met2','test_gomet2'和'test_closeVar'我得到了同樣的錯誤,這是我能夠重現問題的最少的代碼行 – Marcelo 2012-07-23 13:52:11
然後更新問題。 – 2012-07-23 14:07:55