Remove waiting from ElementProxy methods#211
Conversation
5899d05 to
dceaaa4
Compare
skapfer
left a comment
There was a problem hiding this comment.
I like this change, because predicate methods should not implicitly wait for stuff to happen.
Two comments though
|
|
||
| options_or_locator = args.pop | ||
| options = if options_or_locator.is_a?(Hash) | ||
| options_or_locator.dup.merge(wait: wait) |
There was a problem hiding this comment.
The .dup. is unnecessary here because Hash::merge returns a copy
| true | ||
| rescue ElementNotVisible | ||
| false | ||
| reload_element |
There was a problem hiding this comment.
Will this not raise LoadElementFailed in element.rb line 129 if the element is not visible?
Similar for the other predicates. I think the test stub behaves different from the real Element.rb in element_proxy_test.rb
There was a problem hiding this comment.
The reload_element method doesn't care if the element is visible or not, it will only raise an exception if the element doesn't exist.
There are 3 possible cases:
-
The element exists and is visible.
The element will be loaded and the method will returntrue. -
The element exists and is not visible:
The element will be loaded and the method will returnfalse. -
The element does not exist:
The constructor ofElementwill raiseLoadElementFailed. This is caught inElementProxy#reload_element, which will result in@loaded_element = nil. Thevisible?method would then returnfalse.
The `ElementProxy` class has a set of methods that query the state of the element. ``` visible? hidden? present? absent? ``` These methods all include waiting, so instead of just querying the state they *wait* for the condition to be `true`. This causes considerable performance issues due to developers not being aware of this behavior. Since we have other methods for waiting for elements to be visible / hidden / present / absent, these methods should not wait at all.
dceaaa4 to
bfba105
Compare
bfba105 to
1f78012
Compare
skapfer
left a comment
There was a problem hiding this comment.
Looks good to me, hope we don't have too many tests to fix for this!
| true | ||
| rescue ElementNotVisible | ||
| false | ||
| reload_element |
The
ElementProxyclass has a set of methods that query the state of the element:These methods all include waiting, so instead of just querying the state they wait for the condition to be
true.This causes considerable performance issues due to developers not being aware of this behavior. Since we have other methods for waiting for elements to be visible / hidden / present / absent, these methods should not wait at all.