is 'element.wait_until' broken in page_object 2.0.0?

392 views Asked by At

Using Watir 6.0.3, page object 2.0.0 and Ruby 2.1.9

As per latest watir and page-object changes changed below code to

wait_until(DEFAULT_WAIT_TIME.to_i, 'Login button not found when waiting for the login page to load') do
  login_element.visible?
end

to

message = "Login button not found when waiting for the login page to load"
login_element.wait_until(timeout: timeout, message: message, &:visible?)

but getting undefined method 'zero?' for #<Hash:0x4991340> (NoMethodError)error.

however if I get rid of page-object locator shown below Watir 'wait_until'works as expected.

message = "Login button not found when waiting for the login page to load"
browser.button(name: 'login').wait_until(timeout: 10, message: message, &:visible?)
1

There are 1 answers

0
Justin Ko On

The Element#wait_until method is defined as:

def wait_until(timeout=::PageObject.default_element_wait, message=nil, &block)
  Object::Watir::Wait.until(timeout: timeout, message: message, &block)
end

Notice that timeout and message are normal parameters rather than keyword arguments. As a result, the usage needs to be:

login_element.wait_until(timeout, message, &:visible?)

That said, Element#wait_until is still broken. The way that Object::Watir::Wait.until is called will result in a NoMethodError due to object being nil in the Watir method. Until a fix is released, you can monkey patch Page-Object using (included after you require 'page-object'):

module PageObject
  module Platforms
    module WatirWebDriver
      module Element
        def wait_until(timeout=::PageObject.default_element_wait, message=nil, &block)
          element.wait_until(timeout: timeout, message: message, &block)
        end
       end
     end
   end
 end