当前位置:网站首页>Selenium mouse sliding operation event

Selenium mouse sliding operation event

2022-07-07 09:08:00 Song_ Lun

selenium Mouse operation events Slide the mouse over the control to display the drop-down data
ActionChains

import time
from selenium import webdriver
from selenium.webdriver import ActionChains


def xuanting():
    """  Baidu mouse moves to display drop-down data  :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()

 Insert picture description here

原网站

版权声明
本文为[Song_ Lun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130628527194.html