一、webdriver中将鼠标的操作封装在ActionChains类中

(from selenium.webdriver.common.action_chains import ActionChains

) 1.双击

  1. ActionChains(driver).double_click(element)

2.右击

  1. ActionChains(driver).context_click(element)

3.拖动

  1. ActionChains(driver).drag_and_drop(element)

4.鼠标悬停

  1. ActionChains(driver).move_to_element(element)

5.执行所有存储在ActionChains中的操作

  1. ActionChains(driver).move_to_element(element).perform()

二、Keys()类提供了键盘上几乎所有按键的方法, send_keys()方法可以用来输入键盘上的按键, 甚至是组合键, 如 Ctrl+A、 Ctrl+C 等

(from selenium.webdriver.common.keys import Keys)

全选操作

  1. send_keys(Keys.CONTROL, 'a')

删除操作

  1. send_keys(Keys.BACK_SPACE)