2
votes
  • Ruby 1.9.3p327
  • watir-webdriver 0.6.1

On a fresh Ruby install, with a fresh webdriver install, I am unable to use wait or present? with nonpresent elements without causing non-Watir Timeout errors.

In the below example, id 'gb_32' is on the page, but hidden. Id 'gb_50000' does not exist. In both cases "present?" should return false, but the second one gives me a timeout error after 60 seconds. Any ideas why this could happen?

    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

Thanks.

1
I managed to put together a kludge for now by using explicit timeouts in the "present?" and "until" methods. Something like this: Timeout::timeout(input_timeout=1) do; #Default webdriver command here; end; rescue Timeout::Error; raise TimeoutError; endVirtuoso
Can you share link to the page or relevant HTML?Željko Filipin
I think it's down to the network driver. The page I was looking at was "www.google.com". The fault still appears on "about:blank" when I try looking for exists? or present? for nonpresent elements.Virtuoso

1 Answers

4
votes

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.