seleium 鼠标悬停事件

  seleium 教程:https://www.yiibai.com/selenium

  seleium官网:https://www.seleniumhq.org/docs/

  1、鼠标悬停

    例如,下图

    

    鼠标悬停到“个人中心”

    

    鼠标移动到“退出”

    

    

    

#引入
from selenium.webdriver.common.action_chains import ActionChains

# 定位个人中心
personal = self.driver.find_element_by_class_name("UserLoginOK")
# 鼠标悬停在上面
ActionChains(self.driver).move_to_element(personal).perform()

# 定位退出
logout = self.driver.find_element_by_class_name("LogOut")
# 鼠标悬停在退出上面
ActionChains(self.driver).move_to_element(logout).perform()
if logout:
    href = logout.get_attribute("href")
    # 退出
    self.driver.execute_script(href)

 

 

 

 

 

 

 

 

posted on 2018-12-13 10:58  shaomine  阅读(985)  评论(0编辑  收藏  举报