Skip to content

Commit a3c91ba

Browse files
committed
A method to click on a list of elements in succession.
1 parent b80fedc commit a3c91ba

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import pytest
1111
import sys
12+
import time
1213
import unittest
1314
from seleniumbase.config import settings
1415
from seleniumbase.core import browser_launcher
@@ -51,6 +52,15 @@ def click(self, selector, by=By.CSS_SELECTOR,
5152
if settings.WAIT_FOR_RSC_ON_CLICKS:
5253
self.wait_for_ready_state_complete()
5354

55+
def click_chain(self, selectors_list, by=By.CSS_SELECTOR,
56+
timeout=settings.SMALL_TIMEOUT, spacing=0):
57+
""" This method clicks on a list of elements in succession.
58+
'spacing' is the amount of time to wait between clicks. (sec) """
59+
for selector in selectors_list:
60+
self.click(selector, by=by, timeout=timeout)
61+
if spacing > 0:
62+
time.sleep(spacing)
63+
5464
def click_link_text(self, link_text, timeout=settings.SMALL_TIMEOUT):
5565
element = self.wait_for_link_text_visible(link_text, timeout=timeout)
5666
element.click()

0 commit comments

Comments
 (0)