from selenium import webdriver # 导入webdriver包
import time
from selenium.webdriver.common.keys import Keys
driver=webdriver.Chrome()
driver.maximize_window() # 最大化浏览器
driver.implicitly_wait(30)
driver.get("http://oss.52studyit.net/webzdh/zucea.html") # 通过get()方法,打开一个url站点
#输入用户名:admin1,暂停2秒
ele_userA=driver.find_element_by_id("userA")
ele_userA.send_keys("admin1")
time.sleep(2)
#删除字符1:模拟BackSpace
ele_userA.send_keys(Keys.BACK_SPACE)
time.sleep(2)
#全选用户名:admin:模拟CTRL+A
ele_userA.send_keys(Keys.CONTROL,"a")
time.sleep(2)
#复制用户名:admin:模拟CTRL+C
ele_userA.send_keys(Keys.CONTROL,"c")
time.sleep(2)
#粘贴到密码框:模拟CTRL+V
ele_pwdA=driver.find_element_by_id("passwordA")
ele_pwdA.send_keys(Keys.CONTROL,"v")
time.sleep(5)
driver.quit() # 关闭并退出浏览器