selenium python 鼠标事件操作 下拉框
1 # -*- coding:utf-8 -*- 2 from selenium import webdriver 3 from selenium.webdriver.common.action_chains import ActionChains 4 from selenium.webdriver.support.ui import WebDriverWait 5 import time 6 7 driver = webdriver.Firefox(executable_path='/Users/huiliang/Downloads/geckodriver') 8 driver.get("http://edu.csdn.net/") 9 driver.implicitly_wait(10) 10 11 ''' 12 思路说明: 13 首先内容定位导航元素,然后鼠标移动到该元素上面 14 其次内容定位子元素,然后点击进入该页面 15 ''' 16 ele = driver.find_element_by_link_text(u"人工智能") 17 ActionChains(driver).move_to_element(ele).perform() 18 sub_ele = driver.find_element_by_link_text(u'语音识别') 19 sub_ele.click() 20 21 time.sleep(10) 22 driver.quit()