import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
driver =webdriver.Chrome()
driver.maximize_window()
driver.get("http://www.baidu.com")
#鼠标操作:ActionsChains类
#1、找到需要操作的元素
#2、实例化ActionsChains类
#3、调用鼠标行为
#4、调用perform()执行鼠标动作
ele =driver.find_element(By.XPATH,'//span[@id="s-usersetting-top"]')
ActionChains(driver).move_to_element(ele).perform() #鼠标悬浮
loc =(By.XPATH,'//a[text()="高级搜索"]')
WebDriverWait(driver,10).until(EC.presence_of_element_located(loc))
driver.find_element(*loc).click()
# time.sleep(3)
# driver.find_element(By.XPATH,'//div[@class="c-select adv-ft-select"]').click()
# time.sleep(2)
# driver.find_element(By.XPATH,'//p[@data-value="doc"]').click()
# time.sleep(2)
# driver.find_element(By.XPATH,'//p[@data-value="xls"]').click()
# time.sleep(2)--
# driver.find_element(By.XPATH,'//p[@data-value="ppt"]').click()
time.sleep(5)
driver.quit()