2
  • 红宝石 1.9.3p327
  • Watir-webdriver 0.6.1

在全新的 Ruby 安装和全新的 webdriver 安装中,我无法使用等待或呈现?使用不存在的元素而不会导致非Watir Timeout 错误。

在下面的示例中,id 'gb_32' 在页面上,但被隐藏。ID 'gb_50000' 不存在。在这两种情况下“在场?” 应该返回 false,但第二个在 60 秒后给我一个超时错误。任何想法为什么会发生这种情况?

    irb(main):014:0> b.link(:id,'gb_32').present?
    => false
    irb(main):015:0> b.link(:id,'gb_50000').present?
    Timeout::Error: Timeout::Error
            from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
            from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
            from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
            from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
            from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
            from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
            from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
            from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
            from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
            from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1293:in `request'
            from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
            from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745: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.25.0/lib/selenium/webdriver/remote/http/default.rb:82:in `response_for'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:38:in `request'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:576:in `execute'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:544:in `find_element_by'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/search_context.rb:42:in `find_element'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/locators/element_locator.rb:247:in `by_id'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/locators/element_locator.rb:26:in `locate'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/element.rb:384:in `locate'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/element.rb:362:in `assert_exists'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/element.rb:37:in `exists?'
            from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/element.rb:296:in `present?'
    from (irb):15

谢谢。

4

1 回答 1

4

I'd add this as a comment but evidently I can't yet. Are you using Firefox 17? Watir-webdriver isn't yet compatible with 17, so if you are then try reverting to Firefox 16 and see if your code works. I understand that a watir-webdriver update to resolve this compatibility issue is being released next week.

于 2012-11-30T10:32:07.957 回答