1

我对 Watir 完全陌生,试图找出基础知识,以便我们可以用它来测试我们的网站。

问题是,在我第一次执行 'Watir in 5 minutes' 之后browser.goto,我似乎失去了与浏览器窗口的连接。窗口仍然存在,但我不能再从 irb 中“命令”它。

我只是得到这个错误:

C:\>irb
DL is deprecated, please use Fiddle
irb(main):001:0> require "watir-webdriver"
=> true
irb(main):002:0> ie = Watir::Browser.new :ie
Started InternetExplorerDriver server (32-bit)
2.32.3.0
Listening on port 5555
=> #<Watir::Browser:0x..f3e539e40 url="http://localhost:5555/" title="WebDriver"
>
irb(main):003:0> ie.goto "google.com"
=> "http://localhost:5555/"
irb(main):004:0> ie.goto "stackoverflow.com"
Selenium::WebDriver::Error::NoSuchWindowError: Unable to get browser
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/response.rb:52:in `assert_ok'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/response.rb:15:in `initialize'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/http/common.rb:59:in `new'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/http/default.rb:66:in `request'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/http/common.rb:40:in `call'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/bridge.rb:619:in `raw_execute'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/bridge.rb:597:in `execute'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/remote/bridge.rb:103:in `get'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.32.1/l
ib/selenium/webdriver/common/navigation.rb:14:in `to'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/watir-webdriver-0.6.4/lib/w
atir-webdriver/browser.rb:77:in `goto'
        from (irb):4
        from C:/Ruby200-x64/bin/irb:12:in `<main>'
irb(main):005:0>

我使用的是 Win7 x64 和 Ruby x64,但使用的是 32 位 IE。

4

1 回答 1

2

尝试确保您访问的所有站点以及您的默认主页都位于同一个安全区域(例如“受信任”),看看是否会有所不同。

于 2013-05-08T23:42:10.620 回答