# 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()