from selenium import webdriver
from selenium.webdriver.common.keys import Keys
#打开浏览器
dr = webdriver.chrome()
dr.get("https://www.baidu.com")
#点击登录按钮
dr.find_element_by_link_text("登录").click()
#点击 用户登录
dr.find_element_by_id("TANGRAM__PSP_10__footerULoginBtn").click()
#输入用户名
# element = dr.find_element_by_id("passport-login-pop-api")
userName = dr.find_element_by_id("TANGRAM__PSP_10__userName")
userName.send_keys("username")
#模拟Backspace退格键删除
userName.send_keys(Keys.BACKSPACE)
#模拟全选键ctrl + a
userName.send_keys(Keys.CONTROL,'a')
#模拟键盘的剪切ctrl + x
userName.send_keys(Keys.CONTROL,'x')
#模拟键盘的粘贴ctrl + v
userName.send_keys(Keys.CONTROL,'v')
原文路径为:https://www.cnblogs.com/aanb/p/10299254.html