@@ -976,14 +976,15 @@ def find_visible_elements(self, selector, by=By.CSS_SELECTOR, limit=0):
976
976
def click_visible_elements (self , selector , by = By .CSS_SELECTOR , limit = 0 ):
977
977
""" Finds all matching page elements and clicks visible ones in order.
978
978
If a click reloads or opens a new page, the clicking will stop.
979
+ If no matching elements appear, an Exception will be raised.
980
+ If "limit" is set and > 0, will only click that many elements.
981
+ Also clicks elements that become visible from previous clicks.
979
982
Works best for actions such as clicking all checkboxes on a page.
980
- Example: self.click_visible_elements('input[type="checkbox"]')
981
- If "limit" is set and > 0, will only click that many elements. """
982
- elements = []
983
- try :
984
- elements = self .find_visible_elements (selector , by = by )
985
- except Exception :
986
- elements = self .find_elements (selector , by = by )
983
+ Example: self.click_visible_elements('input[type="checkbox"]') """
984
+ selector , by = self .__recalculate_selector (selector , by )
985
+ self .wait_for_element_present (
986
+ selector , by = by , timeout = settings .SMALL_TIMEOUT )
987
+ elements = self .find_elements (selector , by = by )
987
988
click_count = 0
988
989
for element in elements :
989
990
if limit and limit > 0 and click_count >= limit :
0 commit comments