MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / jquery_click_all

Method jquery_click_all

seleniumbase/fixtures/base_case.py:7263–7299  ·  view source on GitHub ↗

Clicks all matching elements using jQuery.

(self, selector, by="css selector", timeout=None)

Source from the content-addressed store, hash-verified

7261 self.__demo_mode_pause_if_active()
7262
7263 def jquery_click_all(self, selector, by="css selector", timeout=None):
7264 """Clicks all matching elements using jQuery."""
7265 self.__check_scope()
7266 if not timeout or timeout is True:
7267 timeout = settings.SMALL_TIMEOUT
7268 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
7269 timeout = self.__get_new_timeout(timeout)
7270 original_selector = selector
7271 selector, by = self.__recalculate_selector(selector, by, xp_ok=False)
7272 self.wait_for_element_present(selector, by=by, timeout=timeout)
7273 if self.is_element_visible(selector, by=by):
7274 self.__demo_mode_highlight_if_active(selector, by)
7275 css_selector = self.convert_to_css_selector(selector, by=by)
7276 click_script = """jQuery('%s').click();""" % css_selector
7277 if (
7278 self.recorder_mode
7279 and self.__current_url_is_recordable()
7280 and self.get_session_storage_item("pause_recorder") == "no"
7281 ):
7282 time_stamp = self.execute_script("return Date.now();")
7283 tag_name = None
7284 href = ""
7285 if ":contains\\(" not in css_selector:
7286 tag_name = self.execute_script(
7287 "return document.querySelector('%s').tagName.toLowerCase()"
7288 ";" % css_selector
7289 )
7290 if tag_name == "a":
7291 href = self.execute_script(
7292 "return document.querySelector('%s').href;" % css_selector
7293 )
7294 origin = self.get_origin()
7295 href_origin = [href, origin]
7296 action = ["jq_ca", original_selector, href_origin, time_stamp]
7297 self.__extra_actions.append(action)
7298 self.safe_execute_script(click_script)
7299 self.__demo_mode_pause_if_active()
7300
7301 def hide_element(self, selector, by="css selector"):
7302 """Hide the first element on the page that matches the selector."""

Callers 1

jquery_click_allFunction · 0.80

Calls 13

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
is_element_visibleMethod · 0.95
execute_scriptMethod · 0.95
get_originMethod · 0.95
safe_execute_scriptMethod · 0.95

Tested by

no test coverage detected