selenium鼠标操作事件 鼠标滑动到控件显示下拉数据
ActionChains
import time
from selenium import webdriver
from selenium.webdriver import ActionChains
def xuanting():
"""
百度鼠标移动显示下拉数据
:return:
"""
driver = webdriver.Chrome()
driver.get('https://www.baidu.com/')
driver.maximize_window()
hover_element = driver.find_element_by_css_selector('#s-top-left > div > a')
ActionChains(driver).move_to_element(hover_element).perform()
xuan = driver.find_element_by_css_selector(
'#s-top-more > div.s-top-more-content.row-2.clearfix > a:nth-child(4) > img')
time.sleep(10)
xuan.click()
driver.quit()
if __name__ == '__main__':
xuanting()