-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The 'when_present' and 'present?' methods behave strangely when chained #432
Comments
This is because of this issue: https://github.com/watir/watir-webdriver/pull/216 It looks like @jarmo's suggestion essentially bypasses the when_present call when you are calling present? on the Decorator. |
It's always nice to read things from 3 years ago and be surprised of what I've written :) Anyway, I agree that this behavior seems strange, but so does the assertion/spec itself. Reading the spec it seems surprising that there's an assertion for element's @titusfortner seems to be right here because as I understand then The really correct solution would be to destroy ActiveSupport in it's entirety, but we all know that this will not happen... Having that in mind, maybe something like this would work: class WhenPresentDecorator < BaseDecorator
def present?
Watir::Wait.until(@timeout, @message) { wait_until }
true
rescue Watir::Wait::TimeoutError
false
end
private
def wait_until
@element.present?
end
end |
I know exactly what my 3 year old comments often look like. :) I think this code is right. I pushed it to a branch to make sure Travis likes it. @jarmo do you want to do a PR with that code, or would you rather I commit it? |
Feel free to commit yourself :) Just don't forget to add spec as well ;) |
Merged: 9aa1ddd |
In my test suite I managed to get an error:
And this is not the kind of error that I expected to see, should something go wrong.
Is there some kind of timing issue between the methods, or do they somehow evaluate presence differently?
Using 'when_present.exists?' instead seems to do the trick.
The text was updated successfully, but these errors were encountered: