@@ -1029,17 +1029,21 @@ def find_visible_elements(self, selector, by=By.CSS_SELECTOR, limit=0):
1029
1029
v_elems = v_elems [:limit ]
1030
1030
return v_elems
1031
1031
1032
- def click_visible_elements (self , selector , by = By .CSS_SELECTOR , limit = 0 ):
1032
+ def click_visible_elements (
1033
+ self , selector , by = By .CSS_SELECTOR , limit = 0 , timeout = None ):
1033
1034
""" Finds all matching page elements and clicks visible ones in order.
1034
1035
If a click reloads or opens a new page, the clicking will stop.
1035
1036
If no matching elements appear, an Exception will be raised.
1036
1037
If "limit" is set and > 0, will only click that many elements.
1037
1038
Also clicks elements that become visible from previous clicks.
1038
1039
Works best for actions such as clicking all checkboxes on a page.
1039
1040
Example: self.click_visible_elements('input[type="checkbox"]') """
1041
+ if not timeout :
1042
+ timeout = settings .SMALL_TIMEOUT
1043
+ if self .timeout_multiplier and timeout == settings .SMALL_TIMEOUT :
1044
+ timeout = self .__get_new_timeout (timeout )
1040
1045
selector , by = self .__recalculate_selector (selector , by )
1041
- self .wait_for_element_present (
1042
- selector , by = by , timeout = settings .SMALL_TIMEOUT )
1046
+ self .wait_for_element_present (selector , by = by , timeout = timeout )
1043
1047
elements = self .find_elements (selector , by = by )
1044
1048
if self .browser == "safari" :
1045
1049
if not limit :
@@ -1088,10 +1092,17 @@ def click_visible_elements(self, selector, by=By.CSS_SELECTOR, limit=0):
1088
1092
except (StaleElementReferenceException , ENI_Exception ):
1089
1093
return # Probably on new page / Elements are all stale
1090
1094
1091
- def click_nth_visible_element (self , selector , number , by = By .CSS_SELECTOR ):
1095
+ def click_nth_visible_element (
1096
+ self , selector , number , by = By .CSS_SELECTOR , timeout = None ):
1092
1097
""" Finds all matching page elements and clicks the nth visible one.
1093
1098
Example: self.click_nth_visible_element('[type="checkbox"]', 5)
1094
1099
(Clicks the 5th visible checkbox on the page.) """
1100
+ if not timeout :
1101
+ timeout = settings .SMALL_TIMEOUT
1102
+ if self .timeout_multiplier and timeout == settings .SMALL_TIMEOUT :
1103
+ timeout = self .__get_new_timeout (timeout )
1104
+ selector , by = self .__recalculate_selector (selector , by )
1105
+ self .wait_for_element_present (selector , by = by , timeout = timeout )
1095
1106
elements = self .find_visible_elements (selector , by = by )
1096
1107
if len (elements ) < number :
1097
1108
raise Exception ("Not enough matching {%s} elements of type {%s} to"
0 commit comments