2

与 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()
4

1 回答 1

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()
于 2021-05-17T03:37:34.730 回答