Skip to content
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

Merged
merged 8 commits into from
May 3, 2016
Merged

Find visible elements #2041

merged 8 commits into from
May 3, 2016

Conversation

remcowesterhoud
Copy link
Contributor

Adds an expected conditions for finding visible elements as list. Right now this is only possible for the presence of 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.
@lukeis
Copy link
Member

lukeis commented May 2, 2016

@jleyba jleyba added the C-py label May 2, 2016
def __call__(self, driver):
visible_elements = []
for element in _find_elements(driver, self.locator):
if _element_if_visible(element) is not False:
Copy link
Contributor

@cgoldberg cgoldberg May 2, 2016

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):

@remcowesterhoud
Copy link
Contributor Author

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remcowesterhoud
Copy link
Contributor Author

remcowesterhoud commented May 3, 2016

@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

@lukeis lukeis merged commit 116adb8 into SeleniumHQ:master May 3, 2016
@lukeis
Copy link
Member

lukeis commented May 3, 2016

awesome, thanks for the patch! (and the reworks :) )

AutomatedTester pushed a commit that referenced this pull request May 18, 2016
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants