@@ -5687,13 +5687,22 @@ def click_xpath(self, xpath):
56875687 self.click(xpath, by="xpath")
56885688
56895689 def js_click(
5690- self, selector, by="css selector", all_matches=False, scroll=True
5690+ self,
5691+ selector,
5692+ by="css selector",
5693+ all_matches=False,
5694+ timeout=None,
5695+ scroll=True,
56915696 ):
56925697 """Clicks an element using JavaScript.
56935698 Can be used to click hidden / invisible elements.
56945699 If "all_matches" is False, only the first match is clicked.
56955700 If "scroll" is False, won't scroll unless running in Demo Mode."""
56965701 self.wait_for_ready_state_complete()
5702+ if not timeout or timeout is True:
5703+ timeout = settings.SMALL_TIMEOUT
5704+ if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
5705+ timeout = self.__get_new_timeout(timeout)
56975706 selector, by = self.__recalculate_selector(selector, by, xp_ok=False)
56985707 if by == By.LINK_TEXT:
56995708 message = (
@@ -5706,7 +5715,7 @@ def js_click(
57065715 self.click(selector, by=by)
57075716 return
57085717 element = self.wait_for_element_present(
5709- selector, by=by, timeout=settings.SMALL_TIMEOUT
5718+ selector, by=by, timeout=timeout
57105719 )
57115720 if not page_actions.is_element_clickable(self.driver, selector, by):
57125721 self.wait_for_ready_state_complete()
@@ -5818,9 +5827,7 @@ def js_click_if_present(self, selector, by="css selector", timeout=0):
58185827 self.js_click(selector, by=by)
58195828 elif timeout > 0:
58205829 try:
5821- self.wait_for_element_present(
5822- selector, by=by, timeout=timeout
5823- )
5830+ self.wait_for_element_present(selector, by=by, timeout=timeout)
58245831 except Exception:
58255832 pass
58265833 if self.is_element_present(selector, by=by):
@@ -5836,27 +5843,29 @@ def js_click_if_visible(self, selector, by="css selector", timeout=0):
58365843 self.js_click(selector, by=by)
58375844 elif timeout > 0:
58385845 try:
5839- self.wait_for_element_visible(
5840- selector, by=by, timeout=timeout
5841- )
5846+ self.wait_for_element_visible(selector, by=by, timeout=timeout)
58425847 except Exception:
58435848 pass
58445849 if self.is_element_visible(selector, by=by):
58455850 self.js_click(selector, by=by)
58465851
5847- def js_click_all(self, selector, by="css selector"):
5852+ def js_click_all(self, selector, by="css selector", timeout=None ):
58485853 """Clicks all matching elements using pure JS. (No jQuery)"""
5849- self.js_click(selector, by="css selector", all_matches=True)
5854+ self.js_click(
5855+ selector, by="css selector", all_matches=True, timeout=timeout
5856+ )
58505857
5851- def jquery_click(self, selector, by="css selector"):
5858+ def jquery_click(self, selector, by="css selector", timeout=None ):
58525859 """Clicks an element using jQuery. (Different from using pure JS.)
58535860 Can be used to click hidden / invisible elements."""
58545861 self.__check_scope()
5862+ if not timeout or timeout is True:
5863+ timeout = settings.SMALL_TIMEOUT
5864+ if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
5865+ timeout = self.__get_new_timeout(timeout)
58555866 original_selector = selector
58565867 selector, by = self.__recalculate_selector(selector, by, xp_ok=False)
5857- self.wait_for_element_present(
5858- selector, by=by, timeout=settings.SMALL_TIMEOUT
5859- )
5868+ self.wait_for_element_present(selector, by=by, timeout=timeout)
58605869 if self.is_element_visible(selector, by=by):
58615870 self.__demo_mode_highlight_if_active(selector, by)
58625871 selector = self.convert_to_css_selector(selector, by=by)
@@ -5887,14 +5896,16 @@ def jquery_click(self, selector, by="css selector"):
58875896 self.safe_execute_script(click_script)
58885897 self.__demo_mode_pause_if_active()
58895898
5890- def jquery_click_all(self, selector, by="css selector"):
5899+ def jquery_click_all(self, selector, by="css selector", timeout=None ):
58915900 """Clicks all matching elements using jQuery."""
58925901 self.__check_scope()
5902+ if not timeout or timeout is True:
5903+ timeout = settings.SMALL_TIMEOUT
5904+ if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
5905+ timeout = self.__get_new_timeout(timeout)
58935906 original_selector = selector
58945907 selector, by = self.__recalculate_selector(selector, by, xp_ok=False)
5895- self.wait_for_element_present(
5896- selector, by=by, timeout=settings.SMALL_TIMEOUT
5897- )
5908+ self.wait_for_element_present(selector, by=by, timeout=timeout)
58985909 if self.is_element_visible(selector, by=by):
58995910 self.__demo_mode_highlight_if_active(selector, by)
59005911 css_selector = self.convert_to_css_selector(selector, by=by)
0 commit comments