-
Notifications
You must be signed in to change notification settings - Fork 37
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
Adds Finds support to is_element_present() #17
Conversation
Hi martinpelikan! Thanks for your PR. It looks good to me. This behavior is kind of tricky but the changes do not make the state of things worse. However before we merge this PR please could you:
One for SamplePage.anchor_list field (https://github.com/martinpelikan/webium/blob/f9a8a654f4dc147f00f79ebdeb8f9fc212f99f9b/tests/simple_page/__init__.py#L54)
|
raise WebiumException('No element "{0}" within container {1}'.format(element_name, self)) | ||
if isinstance(element, list): | ||
if element: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nested if
is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, all([])
produces True
. So, it depends on what you expect from Finds which does not contain any visible elements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are needed to display what behaviour we are trying to achieve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semantically, it might be more clear if I wrote this as if element != []:
instead of if element:
. I can change it to that if you prefer. This is mostly my habit when checking for empty sequences/iterables.
Finds returns a list of WebElements, not a single WebElement, and thus is_displayed() fails when called upon said list. This commit adds handling to check if there are any elements in the list, and if so, determines if they are all visible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Context
I'm still quite new to the page object design pattern, so this may not normally come up. I have a table of elements that need to be deleted one at a time via a menu/option. My solution is to iterate while there are still elements visible and delete them one at a time (avoiding the stale element reference in doing so). The problem is that Webium's nice
is_element_present()
method fails for Finds. This is my fix, which seems to work for me, and should not break existing behaviour. The question is, if it should check that all elements are visible, or if only the first is necessary...Error Encountered