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

Function uc_gui_click_x_y

seleniumbase/core/browser_launcher.py:1258–1313  ·  view source on GitHub ↗
(driver, x, y, timeframe=0.25)

Source from the content-addressed store, hash-verified

1256
1257
1258def uc_gui_click_x_y(driver, x, y, timeframe=0.25):
1259 gui_lock = FileLock(constants.MultiBrowser.PYAUTOGUILOCK)
1260 with gui_lock: # Prevent issues with multiple processes
1261 install_pyautogui_if_missing(driver)
1262 import pyautogui
1263 pyautogui = get_configured_pyautogui(pyautogui)
1264 connected = True
1265 width_ratio = 1.0
1266 if IS_WINDOWS:
1267 connected = driver.is_connected()
1268 if (
1269 not connected
1270 and not getattr(sb_config, "_saved_width_ratio", None)
1271 and not __is_cdp_swap_needed(driver)
1272 ):
1273 driver.reconnect(0.1)
1274 if IS_WINDOWS and not __is_cdp_swap_needed(driver):
1275 window_rect = driver.get_window_rect()
1276 width = window_rect["width"]
1277 height = window_rect["height"]
1278 win_x = window_rect["x"]
1279 win_y = window_rect["y"]
1280 scr_width = pyautogui.size().width
1281 driver.maximize_window()
1282 win_width = driver.get_window_size()["width"]
1283 width_ratio = round(float(scr_width) / float(win_width), 2) + 0.01
1284 if width_ratio < 0.45 or width_ratio > 2.55:
1285 width_ratio = 1.01
1286 sb_config._saved_width_ratio = width_ratio
1287 driver.minimize_window()
1288 driver.set_window_rect(win_x, win_y, width, height)
1289 elif IS_WINDOWS and __is_cdp_swap_needed(driver):
1290 window_rect = driver.cdp.get_window_rect()
1291 width = window_rect["width"]
1292 height = window_rect["height"]
1293 win_x = window_rect["x"]
1294 win_y = window_rect["y"]
1295 scr_width = pyautogui.size().width
1296 driver.cdp.maximize()
1297 win_width = driver.cdp.get_window_size()["width"]
1298 width_ratio = round(float(scr_width) / float(win_width), 2) + 0.01
1299 if width_ratio < 0.45 or width_ratio > 2.55:
1300 width_ratio = 1.01
1301 sb_config._saved_width_ratio = width_ratio
1302 driver.cdp.minimize()
1303 driver.cdp.set_window_rect(win_x, win_y, width, height)
1304 if IS_WINDOWS:
1305 x = x * (width_ratio + 0.03)
1306 y = y * (width_ratio - 0.03)
1307 _uc_gui_click_x_y(driver, x, y, timeframe=timeframe, uc_lock=False)
1308 return
1309 with suppress(Exception):
1310 page_actions.switch_to_window(
1311 driver, driver.current_window_handle, 2, uc_lock=False
1312 )
1313 _uc_gui_click_x_y(driver, x, y, timeframe=timeframe, uc_lock=False)
1314
1315

Callers 1

get_local_driverFunction · 0.85

Calls 14

get_configured_pyautoguiFunction · 0.85
_uc_gui_click_x_yFunction · 0.85
reconnectMethod · 0.80
maximize_windowMethod · 0.80
minimize_windowMethod · 0.80
__is_cdp_swap_neededFunction · 0.70
is_connectedMethod · 0.45
get_window_rectMethod · 0.45
get_window_sizeMethod · 0.45
set_window_rectMethod · 0.45
maximizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…