selenium学习---鼠标事件之鼠标悬浮操作

目前web界面中涉及到的鼠标悬浮事件应用很广泛,即我们在界面操作时看到的以手形悬浮鼠标于某一个标签上,以百度百科界面为例,实际演示鼠标悬浮事件(move_to_element)的具体实现;

# coding="utf-8"

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep

browser = webdriver.Firefox()
try:
    browser.get("https://baike.baidu.com/")
    elements = browser.find_element_by_link_text("分类")
    actions = ActionChains(browser)
    sleep(5)
    actions.move_to_element(elements)
    sleep(5)
    element_artist = browser.find_element_by_link_text("艺术")
    element_artist.click()
except BaseException as msg:
    print(msg)
finally:
    browser.close()


猜你喜欢

转载自blog.csdn.net/u012605082/article/details/80911722
今日推荐