1 导入相关模块

  1. from selenium.webdriver import ActionChains
  2. from selenium.webdriver.common.keys import Keys

2 先定位元素,再进行鼠标操作

  1. Element=broswer.find_element(By.ID,value)

3 全选:Ctrl+A

  1. Element.send_keys(Keys.CONTROL,"a")

4 复制:Ctrl+C

  1. Element.send_keys(Keys.CONTROL,"c")

5 剪切:Ctrl+X

  1. Element.send_keys(Keys.CONTROL,"x")

6 粘贴:Ctrl+V

  1. Element.send_keys(Keys.CONTROL,"v")

7 空格

  1. Element.send_keys(Keys.SPACE)

8 回车键

  1. Element.send_keys(Keys.ENTER)

9 后退键

  1. Element.send_keys(Keys.BACKSPACE)

10 TAB键

  1. Element.send_keys(Keys.TAB)

11 刷新键

  1. Element.send_keys(Keys.F5)