1

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?

2
  • 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. Nov 20, 2017 at 22:51
  • I added the trace and let it run for a second before resizing the window. gist.github.com/ryanesch/9b589035a1ac0abbd50794dad7219d21
    – Ryan
    Nov 20, 2017 at 23:20

1 Answer 1

4

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.

1
  • Thanks! move did not seem to work but maximize does. I'll try out watir-scroll.gem later.
    – Ryan
    Nov 21, 2017 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.