First, to introduce the package
from selenium.webdriver import ActionChains
list ActionChains method:
click (on_element = None) - Click the left mouse button
context_click (on_element = None) - Right-click
double_click (on_element = None) - Double-click the left mouse button
drag_and_drop (source, target) - an element to drag and then release
move_to_element (to_element) - Move the mouse to an element
perform () - all acts of execution ActionChains
drag_and_drop_by_offset (source, xoffset, yoffset) - drag and then release to a coordinate
key_down (value, element = None) - pressing a key on a keyboard
key_up (value, element = None) - a key release
click_and_hold (on_element = None) - click on the left mouse button, do not let go
move_by_offset (xoffset, yoffset) - mouse from the current position to a coordinate
move_to_element_with_offset (to_element, xoffset, yoffset) - how many positions to move away from an element (left corner) distance
release (on_element = None) - Release the left mouse button on an element position
send_keys (* keys_to_send) - Send a key to the current focus element points
send_keys_to_element (element, * keys_to_send) - Send a key to the specified element
from selenium.webdriver.common.keys import Keys
send_keys (Keys.BACK_SPACE) # Delete key (BackSpace)
send_keys (Keys.SPACE) # spacebar (Space)
send_keys (Keys.TAB) # Tabulator (Tab)
send_keys (Keys.ESCAPE) # backspace key (Esc)
send_keys (Keys.ENTER) # Enter key (Enter)
send_keys(Keys.CONTROL,‘a’) #全选(Ctrl+A)
send_keys(Keys.CONTROL,‘c’) #复制(Ctrl+C)
send_keys (Keys.CONTROL, 'x') # Cut (Ctrl + X)
send_keys (Keys.CONTROL, 'v') # paste (Ctrl + V)
send_keys (Keys.F1) # F1 keyboard
…… ......
send_keys (Keys.F12) # F12 keyboard