import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get('https://pythonav.com/login/')
# 用户名输入值
user = driver.find_element_by_id('id_username')
user.send_keys('alexdsb')
time.sleep(1)
# 全选:
user.send_keys(Keys.CONTROL, 'a')
time.sleep(1)
# 删除:
user.send_keys(Keys.DELETE)
# 删除一个:
user.send_keys(Keys.BACKSPACE)
time.sleep(2)
# 复制:
user.send_keys(Keys.CONTROL, 'c')
time.sleep(3)
# 粘贴:
pwd = driver.find_element_by_id('id_password')
pwd.send_keys(Keys.CONTROL, 'v')
time.sleep(3)
# TAB之后,输入值
pwd.send_keys(Keys.TAB, 'ABC')
# tab之后,直接回车
pwd.send_keys(Keys.TAB, Keys.ENTER)
# 打印键盘事件:
print(dir(Keys))