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

Method click_link_text

seleniumbase/fixtures/base_case.py:1642–1771  ·  view source on GitHub ↗

This method clicks link text on a page.

(self, link_text, timeout=None)

Source from the content-addressed store, hash-verified

1640 return None
1641
1642 def click_link_text(self, link_text, timeout=None):
1643 """This method clicks link text on a page."""
1644 self.__check_scope()
1645 if not timeout:
1646 timeout = settings.SMALL_TIMEOUT
1647 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
1648 timeout = self.__get_new_timeout(timeout)
1649 if self.__is_cdp_swap_needed():
1650 self.cdp.find_element(link_text, timeout=timeout).click()
1651 return
1652 self.__skip_if_esc()
1653 link_text = self.__get_type_checked_text(link_text)
1654 if self.__is_cdp_swap_needed():
1655 self.cdp.click_link(link_text)
1656 return
1657 if self.browser == "safari":
1658 if self.demo_mode:
1659 self.wait_for_link_text_present(link_text, timeout=timeout)
1660 try:
1661 self.__jquery_slow_scroll_to(link_text, by="link text")
1662 except Exception:
1663 element = self.wait_for_link_text_visible(
1664 link_text, timeout=timeout
1665 )
1666 self.__slow_scroll_to_element(element)
1667 o_bs = "" # original_box_shadow
1668 loops = settings.HIGHLIGHTS
1669 selector = self.convert_to_css_selector(
1670 link_text, by="link text"
1671 )
1672 selector = self.__make_css_match_first_element_only(selector)
1673 try:
1674 selector = re.escape(selector)
1675 selector = self.__escape_quotes_if_needed(selector)
1676 self.__highlight_with_jquery(selector, loops, o_bs)
1677 except Exception:
1678 pass # JQuery probably couldn't load. Skip highlighting.
1679 self.__jquery_click(link_text, by="link text")
1680 return
1681 if not self.is_link_text_present(link_text):
1682 self.wait_for_link_text_present(link_text, timeout=timeout)
1683 if not self.demo_mode and not self.slow_mode:
1684 if self.__needs_minimum_wait():
1685 time.sleep(0.04)
1686 pre_action_url = None
1687 with suppress(Exception):
1688 pre_action_url = self.driver.current_url
1689 pre_window_count = len(self.driver.window_handles)
1690 try:
1691 element = self.wait_for_link_text_visible(link_text, timeout=0.2)
1692 self.__demo_mode_highlight_if_active(link_text, by="link text")
1693 try:
1694 self.__element_click(element)
1695 except (Stale_Exception, ENI_Exception, ECI_Exception):
1696 self.wait_for_ready_state_complete()
1697 time.sleep(0.16)
1698 element = self.wait_for_link_text_visible(
1699 link_text, timeout=timeout

Callers 12

clickMethod · 0.95
click_linkMethod · 0.95
klik_linktekstMethod · 0.80
cliquer_texte_du_lienMethod · 0.80
clic_texto_del_enlaceMethod · 0.80
单击链接文本Method · 0.80
clique_texto_do_linkMethod · 0.80
test_get_coffeeMethod · 0.80

Calls 15

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
clickMethod · 0.95
__skip_if_escMethod · 0.95

Tested by 1

test_get_coffeeMethod · 0.64