#coding=utf-8
from selenium import webdriver
import time
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Firefox()
driver.implicitly_wait(10)
driver.get("http://www.baidu.com")
#鼠标悬停在设置链接上
link = driver.find_element_by_link_text('设置')
ActionChains(driver).move_to_element(link).perform()
time.sleep(2)
#打开搜索设置
driver.find_element_by_class_name('setpref').click()
time.sleep(3)
#保存设置
driver.find_element_by_class_name('prefpanelgo').click()
time.sleep(3)
#接收弹出窗口
driver.switch_to_alert().accept()
driver.quit()