selenium 输入框有默认值,用键盘事件解决

from selenium.webdriver.common.keys import Keys
from selenium import webdriver
driver = webdriver.Chrome()
driver.implicitly_wait(5)
driver.get("http://127.0.0.1:8088/login")

driver.find_element_by_name("username").send_keys("libai")
driver.find_element_by_name("password").send_keys("opmsopms123")
driver.find_element_by_class_name("btn-login").click()
# 点击项目管理
driver.find_element_by_css_selector('[href="/project/manage"] > span').click()
# 点击新项目按钮
driver.find_element_by_css_selector('[class="pull-right"]').click()
# 定位到开始日期
ele = driver.find_element_by_name("started")
# 对开始日期输入内容
ele.click()
ele.send_keys(Keys.CONTROL,"a")
ele.send_keys(Keys.BACK_SPACE)
ele.send_keys('2021-07-01')

 

posted @ 2021-07-01 22:12  大熊童鞋  阅读(246)  评论(0编辑  收藏  举报