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

Method click

seleniumbase/fixtures/base_case.py:405–677  ·  view source on GitHub ↗
(
        self, selector, by="css selector", timeout=None, delay=0, scroll=True
    )

Source from the content-addressed store, hash-verified

403 return self.get_element(url) # url is treated like a selector
404
405 def click(
406 self, selector, by="css selector", timeout=None, delay=0, scroll=True
407 ):
408 self.__check_scope()
409 self.__skip_if_esc()
410 if not timeout:
411 timeout = settings.SMALL_TIMEOUT
412 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
413 timeout = self.__get_new_timeout(timeout)
414 original_selector = selector
415 original_by = by
416 selector, by = self.__recalculate_selector(selector, by)
417 if self.__is_cdp_swap_needed():
418 self.cdp.click(selector, timeout=timeout, scroll=scroll)
419 return
420 if delay and (type(delay) in [int, float]) and delay > 0:
421 time.sleep(delay)
422 if page_utils.is_link_text_selector(selector) or by == By.LINK_TEXT:
423 if not self.is_link_text_visible(selector):
424 # Handle a special case of links hidden in dropdowns
425 self.click_link_text(selector, timeout=timeout)
426 return
427 if (
428 page_utils.is_partial_link_text_selector(selector)
429 or by == By.PARTIAL_LINK_TEXT
430 ):
431 if not self.is_partial_link_text_visible(selector):
432 # Handle a special case of partial links hidden in dropdowns
433 self.click_partial_link_text(selector, timeout=timeout)
434 return
435 if self.__is_shadow_selector(selector):
436 self.__shadow_click(selector, timeout)
437 return
438 if self.__needs_minimum_wait() or self.browser == "safari":
439 time.sleep(0.05)
440 element = page_actions.wait_for_element_visible(
441 self.driver,
442 selector,
443 by,
444 timeout=timeout,
445 original_selector=original_selector,
446 )
447 self.__demo_mode_highlight_if_active(original_selector, original_by)
448 if scroll and not self.demo_mode and not self.slow_mode:
449 self.__scroll_to_element(element, selector, by)
450 pre_action_url = None
451 with suppress(Exception):
452 pre_action_url = self.driver.current_url
453 pre_window_count = len(self.driver.window_handles)
454 try:
455 if (
456 by == By.LINK_TEXT
457 and (self.browser == "ie" or self.browser == "safari")
458 ):
459 self.__jquery_click(selector, by=by)
460 elif self.browser == "safari":
461 self.execute_script("arguments[0].click();", element)
462 else:

Callers 15

slow_clickMethod · 0.95
click_chainMethod · 0.95
click_link_textMethod · 0.95
click_if_visibleMethod · 0.95
click_active_elementMethod · 0.95
check_if_uncheckedMethod · 0.95
uncheck_if_checkedMethod · 0.95
hover_and_clickMethod · 0.95
highlight_clickMethod · 0.95
click_xpathMethod · 0.95
js_clickMethod · 0.95

Calls 15

__check_scopeMethod · 0.95
__skip_if_escMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
is_link_text_visibleMethod · 0.95
click_link_textMethod · 0.95
__is_shadow_selectorMethod · 0.95
__shadow_clickMethod · 0.95
__needs_minimum_waitMethod · 0.95

Tested by

no test coverage detected