# coding:utf-8 from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains driver = webdriver.Firefox() driver.get("http://xxxxxxx.com") # 定位鼠标悬停才显示的“退出登录”按钮 mouse = self.driver.find_element_by_xpath("//*[contains(text(),'hello')]") ActionChains(self.driver).move_to_element(mouse).perform() self.driver.find_element_by_xpath("//*[contains(text(),'退出登录')]").click()