首页 > 解决方案 > ActionChains的Python Selenium move_to_element方法不起作用

问题描述

driver = webdriver.Chrome()
driver.get('https://www.wikipedia.org/')
time.sleep(2)
actions = ActionChains(driver)
actions.move_by_offset(500, 500).perform()

move_to_element(),move_to_element_by_offset()

任何功能都不起作用。

没有错误报告。

https://github.com/SeleniumHQ/selenium/issues/7890

标签: seleniumgoogle-chromeselenium-webdriverselenium-chromedriveraction

解决方案


我在您的代码试验中没有看到任何此类问题。但是需要注意的是,ActionChains一种自动化低级别交互的方法,例如鼠标移动、鼠标按钮操作、按键和上下文菜单交互。此类对于执行复杂的操作也很有用,例如悬停和拖放。为了模拟所有这些低级交互复杂动作,使用 ActionChains类,而不是直接使用键盘鼠标

因此,尽管该move_by_offset()方法被明显执行,但您可能无法跟踪/跟踪它。


推荐阅读