from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get("https://www.12306.cn/index/")
time.sleep(5)
# 去掉元素的readonly属性
js = ‘document.getElementById("train_date").removeAttribute("readonly");‘
driver.execute_script(js)
# 清空输入框后输入值
driver.find_element_by_id("train_date").clear()
driver.find_element_by_id("train_date").send_keys("2020-6-6")
# 用js方法输入日期
# js_value = ‘document.getElementById("train_date").value=("2020-6-6");‘
# driver.execute_script(js_value)