python与selenium自动化基础-鼠标和键盘事件

Posted 忆梦,惊梦

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python与selenium自动化基础-鼠标和键盘事件相关的知识,希望对你有一定的参考价值。

二、鼠标和键盘模拟用户行为 

  ①导入 ActionChains:from selenium.webdriver.common.action_chains import ActionChains
  ②用于生成模拟用户行为:ActionChains(driver)
  ③执行存储行为:perform()
  ④例:ele=driver.find_element_by_link_text(arg)
    ActionChains(driver).move_to_element(ele).perform()

二、多窗口切换 

  d.window_handles #所有打开的窗口
  d.switch_to_window(d.window_handles[1]) #根据下标定位窗口

以上是关于python与selenium自动化基础-鼠标和键盘事件的主要内容,如果未能解决你的问题,请参考以下文章