Skip to content

Commit 0c54d09

Browse files
committed
Add the slow_click() method
1 parent d53cdd8 commit 0c54d09

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,21 @@ def click(self, selector, by=By.CSS_SELECTOR,
151151
else:
152152
self.__demo_mode_pause_if_active(tiny=True)
153153

154+
def slow_click(self, selector, by=By.CSS_SELECTOR,
155+
timeout=settings.SMALL_TIMEOUT):
156+
""" Similar to click(), but pauses for a brief moment before clicking.
157+
When used in combination with setting the user-agent, you can often
158+
bypass bot-detection by tricking websites into thinking that you're
159+
not a bot. (Useful on websites that block web automation tools.)
160+
To set the user-agent, use: ``--agent=AGENT``.
161+
Here's an example message from GitHub's bot-blocker:
162+
``You have triggered an abuse detection mechanism...`` """
163+
if not self.demo_mode:
164+
self.click(selector, by=by, timeout=timeout, delay=1.05)
165+
else:
166+
# Demo Mode already includes a small delay
167+
self.click(selector, by=by, timeout=timeout, delay=0.25)
168+
154169
def double_click(self, selector, by=By.CSS_SELECTOR,
155170
timeout=settings.SMALL_TIMEOUT):
156171
from selenium.webdriver import ActionChains

0 commit comments

Comments
 (0)