-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Find visible elements #2041
Find visible elements #2041
Conversation
There already was a way of finding a list of elements that are present on the page, but there was none for finding visible elements. I've created a class that makes this possible.
Can you also add a test for this? The pages that these tests are loading are here: |
def __call__(self, driver): | ||
visible_elements = [] | ||
for element in _find_elements(driver, self.locator): | ||
if _element_if_visible(element) is not False: |
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.
I think this line would be better written as:
if _element_if_visible(element):
Used in the visibility_of_all_elements tests
I've added the tests and replaced the call method with the list comprehension @cgoldberg mentioned. |
self._loadPage("hidden_partially") | ||
try: | ||
elements = WebDriverWait(self.driver, 0.7).until(EC.visibility_of_all_elements_located((By.CLASS_NAME, "redbox"))) | ||
except TimeoutException as e: |
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.
you could assert the exception is raised:
https://docs.python.org/2.7/library/unittest.html#unittest.TestCase.assertRaises
@cgoldberg I've changed it. I did it this way because I saw it being done in other testcases the same way. I've also made the change in this testcase |
I'm an idiot
awesome, thanks for the patch! (and the reworks :) ) |
* EC for finding visible elements There already was a way of finding a list of elements that are present on the page, but there was none for finding visible elements. I've created a class that makes this possible. * Clean * Changed to list comprehension * visibility_of_all_elements tests added * Created hidden_partially.html Used in the visibility_of_all_elements tests * Now uses assertRaises * Fixed usage of assertRaises * Fixed exception name I'm an idiot
X
in the preceding checkbox, I verify that I have signed the Contributor License AgreementAdds an expected conditions for finding visible elements as list. Right now this is only possible for the presence of elements.