Selenium python绑定 - 鼠标移动

时间:2013-06-11 10:22:01

标签: python action

与selenium python绑定相关 - 鼠标悬停在行动

这是使用的代码 试图执行悬停操作,仍然无法正常工作

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

element_to_hover_over = driver.find_element_by_link_text("Documents")
hover = ActionChains(driver).move_to_element(element_to_hover_over)
hover.perform()

1 个答案:

答案 0 :(得分:0)

这是一个例子:

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
browser = webdriver.Chrome()
browser.get('https://tomerlerner.com/')
action = ActionChains(browser)
x = action.move_to_element(browser.find_element_by_xpath('//*[@id="__next"]/section[2]/ul/li[1]/a'))
x.perform()