如何在python Webdriver中鼠标悬停

Pur*_*ell 25 python selenium webdriver selenium-webdriver

看来这是在webdriver中进行悬停/鼠标悬停的方法,至少在java api中是这样的:

Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
action.moveByOffset(1, 1).build().perform();
Run Code Online (Sandbox Code Playgroud)

这可能在Python api中吗?python的webdriver api文档似乎没有提到类似的东西. http://selenium.googlecode.com/svn/trunk/docs/api/py/index.html

如何在python webdriver中完成hover/mouseover?

use*_*110 35

from selenium.webdriver.common.action_chains import ActionChains


def hover(self):
    wd = webdriver_connection.connection
    element = wd.find_element_by_link_text(self.locator)
    hov = ActionChains(wd).move_to_element(element)
    hov.perform()
Run Code Online (Sandbox Code Playgroud)