MCPcopy Index your code
hub / github.com/seleniumbase/SeleniumBase / __highlight

Method __highlight

seleniumbase/fixtures/base_case.py:6642–6718  ·  view source on GitHub ↗

This method uses fancy JavaScript to highlight an element. (Automatically using in S_e_l_e_n_i_u_m_B_a_s_e Demo Mode)

(
        self, selector, by="css selector", loops=None, scroll=True
    )

Source from the content-addressed store, hash-verified

6640 time.sleep(0.065)
6641
6642 def __highlight(
6643 self, selector, by="css selector", loops=None, scroll=True
6644 ):
6645 """This method uses fancy JavaScript to highlight an element.
6646 (Automatically using in S_e_l_e_n_i_u_m_B_a_s_e Demo Mode)"""
6647 self.__check_scope()
6648 selector, by = self.__recalculate_selector(selector, by, xp_ok=False)
6649 element = self.wait_for_element_visible(
6650 selector, by=by, timeout=settings.SMALL_TIMEOUT
6651 )
6652 if not loops:
6653 loops = settings.HIGHLIGHTS
6654 if scroll:
6655 try:
6656 if self.browser != "safari":
6657 scroll_distance = js_utils.get_scroll_distance_to_element(
6658 self.driver, element
6659 )
6660 if abs(scroll_distance) > constants.Values.SSMD:
6661 self.__jquery_slow_scroll_to(selector, by)
6662 else:
6663 self.__slow_scroll_to_element(element)
6664 else:
6665 self.__jquery_slow_scroll_to(selector, by)
6666 except Exception:
6667 self.wait_for_ready_state_complete()
6668 time.sleep(0.12)
6669 element = self.wait_for_element_visible(
6670 selector, by=by, timeout=settings.SMALL_TIMEOUT
6671 )
6672 self.__slow_scroll_to_element(element)
6673 use_element_directly = False
6674 try:
6675 selector = self.convert_to_css_selector(selector, by=by)
6676 except Exception:
6677 # If can't convert to CSS_Selector for JS, use element directly
6678 use_element_directly = True
6679 if self.highlights:
6680 loops = self.highlights
6681 if self.browser == "ie":
6682 loops = 1 # Override previous setting because IE is slow
6683 loops = int(loops)
6684 if self.headless or self.headless2 or self.xvfb:
6685 # Headless modes have less need for highlighting elements.
6686 # However, highlight() may be used as a sleep alternative.
6687 loops = int(math.ceil(loops * 0.5))
6688 o_bs = "" # original_box_shadow
6689 try:
6690 style = element.get_attribute("style")
6691 except Exception:
6692 self.wait_for_ready_state_complete()
6693 time.sleep(0.12)
6694 element = self.wait_for_element_visible(
6695 selector, by="css selector", timeout=settings.SMALL_TIMEOUT
6696 )
6697 style = element.get_attribute("style")
6698 if style:
6699 if "box-shadow: " in style:

Callers 7

highlight_clickMethod · 0.95
highlight_update_textMethod · 0.95
highlight_typeMethod · 0.95
highlight_if_visibleMethod · 0.95
highlightMethod · 0.95
__click_with_offsetMethod · 0.95

Tested by

no test coverage detected