首页 > 解决方案 > 如何通过提供 x,y 坐标使用 selnium(或任何其他 webdriver)在网站上移动鼠标

问题描述

while True:
    cursorx, cursory = pyautogui.position()
    body = driver.find_element_by_css_selector("body")
    actions.move_to_element_with_offset(body, cursorx, cursory)

如何在没有元素的情况下在网站上自由移动鼠标?(没有我像在后台那样与它交互。它是用 python 编写的,带有 pyautogui 来获取光标的位置。

标签: pythonseleniumselenium-chromedriverpyautogui

解决方案


只需将坐标输入到 pyautogui 的 moveTo 方法中:

pyautogui.moveTo(x=1043, y=606)

推荐阅读