1
votes

When I run the following code, I get a timeout waiting for the element:

require 'watir'
require 'webdrivers'

browser = Watir::Browser.new
browser.goto "http://watir.com/examples/forms_with_input_elements.html"
browser.text_field(:id, "new_user_username").set("test")

/home/.gem/ruby/2.4.1/gems/watir-6.9.1/lib/watir/elements/element.rb:618:in `raise_disabled': element present and enabled, but timed out after 30 seconds, waiting for # < Watir::TextField: located: true; {:id=>"new_user_username", :tag_name=>"input"}> to not be disabled (Watir::Exception::ObjectDisabledException)

The chrome window starts and doesn't seem to load. I can force it to load by resizing the window after it starts and everything works fine, but I should not have to take any manual steps. Is there an automated way to force the browser to load?

1
That's odd; I just verified it is working for me. Can you run it with Selenium::WebDrivers.logger.level = :info and put the results into a gist? It shouldn't find the element and then complain about it being disabled if the page hasn't loaded. I want to see what wire calls it is making for that to happen. Actually tack on Watir.logger.level = :debug as well.titusfortner
I added the trace and let it run for a second before resizing the window. gist.github.com/ryanesch/9b589035a1ac0abbd50794dad7219d21Ryan

1 Answers

4
votes

Ah, it's an interactable error. Those can't be easily figured out ahead of time. For some reason chromedriver doesn't think it can move the element to where it can enter text.

You can either try browser.window.maximize, or browser.window.move_to(x,y) or you can use Alex's excellent watir-scroll.gem to position the element inside the viewport where chromedriver can use it.