cheezy / page-object

Gem to implement PageObject pattern in watir-webdriver and selenium-webdriver
MIT License
653 stars 220 forks source link

element.wait_until is broken #408

Closed pravinrmali closed 7 years ago

pravinrmali commented 7 years ago

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 methodzero?' for # (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?)
cheezy commented 7 years ago

I think this is fixed in watir and working properly in page-object. Please reopen if you think there is still a problem.

galinkinlin commented 5 years ago

I know it's been a while, but, pretty much the same issue:

ruby 2.5.5, page-object 2.2.6, watir 6.16.5.

I call some_element.when_visible(30). That's aliased as when_present, which calls: element.wait_until(timeout: timeout, message: "Element not present in #{timeout} seconds", &:present?)

When debugging into element.wait_until (line 169 of element.rb), the arguments look like this: timeout: { message: Element not present in 30 seconds, timeout: 30}, message: nil

It seems to me that the call to element.wait_until shouldn't pass a hash, but just be: element.wait_until(timeout, "Element not present in #{timeout} seconds", &:present?)

jkotests commented 5 years ago

@galinkinlin , what is the issue you are running into? some_element.when_visible(30) seems to be working for me.

galinkinlin commented 5 years ago

Specifically, I am getting the error: NoMethodError: undefined method zero?' for {:timeout=>30, :message=>"Element not present in 30 seconds"}:Hash

However, now that I Iook more closely, I can see that this is only happening for custom elements I've defined, and not everywhere. I must be doing something funky. We were stuck on ruby 1.9.3 until recently, and upgrading everything at once has been quite the chore.

galinkinlin commented 5 years ago

Nevermind, it's even weirder than that. It works just fine when I run it through Intellij's "Evaluate" console, but not when it runs normally. Whatever is going on has got to be my fault.

jkotests commented 5 years ago

Keep in mind that Page-Object's #wait_until method's arguments are not yet in sync with Watir's - see #471. Page-Object only accepts the positional arguments, it does not yet support keywords or a Hash.

galinkinlin commented 5 years ago

I am doing a simple some_element.when_visible(20)