简体   繁体   中英

python selenium does not click on element

I would like to click the calendar, but somehow it does not click (it is on the three bar left-hand side)

driver.get('http://www.sse.com.cn/disclosure/bond/announcement/company/')
wait = WebDriverWait(driver, 50)

wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@class='sse_searchInput']/input[@class='form-control sse_input']"))).click()

Many Thanks!

If you look at the element the inputBox is readonly attribute that's the reason its not allowing any value to enter.

<input class="form-control sse_input" type="text" placeholder="开始时间  至  结束时间" readonly="" lay-key="1">

To make it available to enter the date you can removed the readonly attribute from that element and then enter the date using send_keys .

driver.get('http://www.sse.com.cn/disclosure/bond/announcement/company/')
wait = WebDriverWait(driver, 20)
dateInputBox=wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@class='sse_searchInput']/input[@class='form-control sse_input']")))
driver.execute_script("arguments[0].removeAttribute('readonly')", dateInputBox)
time.sleep(1)
dateInputBox.send_keys("2022-03-31 - 2022-04-22")
print("Date added :" + dateInputBox.get_attribute("value"))
time.sleep(10) # testing purpose to view it

Output: 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM