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]) #根据下标定位窗口

猜你喜欢

转载自www.cnblogs.com/peiya/p/12109684.html