您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

有没有一种方法可以使用Selenium和Python绑定执行鼠标悬停(悬停在元素上)?

有没有一种方法可以使用Selenium和Python绑定执行鼠标悬停(悬停在元素上)?

要进行悬停,您需要使用move_to_element方法

这是一个例子

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

firefox = webdriver.Firefox()
firefox.get('http://foo.bar')
element_to_hover_over = firefox.find_element_by_id("baz")

hover = ActionChains(firefox).move_to_element(element_to_hover_over)
hover.perform()
python 2022/1/1 18:15:33 有473人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶