Home > Back-end >  python selenium does not click on element
python selenium does not click on element

Time:03-23

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!

CodePudding user response:

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

<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: enter image description here

  • Related