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

Method gui_hover_x_y

seleniumbase/core/sb_cdp.py:2738–2787  ·  view source on GitHub ↗
(self, x, y, timeframe=0.27)

Source from the content-addressed store, hash-verified

2736 time.sleep(0.056)
2737
2738 def gui_hover_x_y(self, x, y, timeframe=0.27):
2739 gui_lock = FileLock(constants.MultiBrowser.PYAUTOGUILOCK)
2740 with gui_lock: # Prevent issues with multiple processes
2741 self.__install_pyautogui_if_missing()
2742 import pyautogui
2743 pyautogui = self.__get_configured_pyautogui(pyautogui)
2744 width_ratio = 1.0
2745 if (
2746 shared_utils.is_windows()
2747 and (
2748 not hasattr(sb_config, "_saved_width_ratio")
2749 or not sb_config._saved_width_ratio
2750 )
2751 ):
2752 window_rect = self.get_window_rect()
2753 width = window_rect["width"]
2754 height = window_rect["height"]
2755 win_x = window_rect["x"]
2756 win_y = window_rect["y"]
2757 if (
2758 hasattr(sb_config, "_saved_width_ratio")
2759 and sb_config._saved_width_ratio
2760 ):
2761 width_ratio = sb_config._saved_width_ratio
2762 else:
2763 scr_width = pyautogui.size().width
2764 win_width = self.evaluate("screen.availWidth;")
2765 width_ratio = round(float(scr_width) / float(win_width), 2)
2766 width_ratio += 0.01
2767 if width_ratio < 0.45 or width_ratio > 2.55:
2768 width_ratio = 1.01
2769 sb_config._saved_width_ratio = width_ratio
2770 with suppress(Exception):
2771 self.__set_window_rect(win_x, win_y, width, height)
2772 self.__add_light_pause()
2773 self.bring_active_window_to_front()
2774 elif (
2775 shared_utils.is_windows()
2776 and hasattr(sb_config, "_saved_width_ratio")
2777 and sb_config._saved_width_ratio
2778 ):
2779 width_ratio = sb_config._saved_width_ratio
2780 self.bring_active_window_to_front()
2781 if shared_utils.is_windows():
2782 x = x * width_ratio
2783 y = y * width_ratio
2784 self.__gui_hover_x_y(x, y, timeframe=timeframe, uc_lock=False)
2785 return
2786 self.bring_active_window_to_front()
2787 self.__gui_hover_x_y(x, y, timeframe=timeframe, uc_lock=False)
2788
2789 def gui_hover_element(self, selector, timeframe=0.27):
2790 try:

Callers

nothing calls this directly

Calls 8

get_window_rectMethod · 0.95
evaluateMethod · 0.95
__set_window_rectMethod · 0.95
__add_light_pauseMethod · 0.95
__gui_hover_x_yMethod · 0.95

Tested by

no test coverage detected