selenim the usual mouse click keyboard

Mouse operation

premise

from selenium.webdriver.common.action_chains import ActionChains#鼠标模块

from selenium.webdriver.commom.keys import Keys # keyboard module

Operation name

Method of operation

Right-click

ActionChains(driver).context_click(element).perform()

Hover

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

Drag

ActionChains(driver).drag_and_drop(star_element,end_element).perform()

Double-click

ActionChains(driver).double_click(element).perform()

Analog keyboard input

driver.find_element_by_id(id_name).send_keys(keys.BACKSPACE)#后退

driver.find_element_by_id(id_name).send_keys(keys.CONTROL,’a’)#全选

  • Keys.BACK_SPACE : delete key
  • Keys.SPACE : Spacebar
  • Keys.TAB : the Tab key
  • Keys.ESCAPE : Backspace
  • Keys.ENTER : Enter key
  • Keys.CONTROL, "A" : key combination, Ctrl + A
  • Keys.CONTROL, "X" : key combination, Ctrl + X
  • Keys.CONTROL, "V" : key combination, Ctrl + V
  • Keys.CONTROL, "C" : key combination, Ctrl + C
  • Keys.F1 : F1 key
  • Keys.F12 : F12 key

Guess you like

Origin blog.csdn.net/qq_35577990/article/details/90138059