Skip to content

Commit 456464b

Browse files
committed
Update click_visible_elements()
1 parent d09430d commit 456464b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -976,14 +976,15 @@ def find_visible_elements(self, selector, by=By.CSS_SELECTOR, limit=0):
976976
def click_visible_elements(self, selector, by=By.CSS_SELECTOR, limit=0):
977977
""" Finds all matching page elements and clicks visible ones in order.
978978
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.
979982
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)
987988
click_count = 0
988989
for element in elements:
989990
if limit and limit > 0 and click_count >= limit:

0 commit comments

Comments
 (0)