1

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!

2
  • what is the date that you want to enter? Commented Mar 22, 2022 at 7:54
  • @cruisepandey any date range, it doesn't matter Commented Mar 22, 2022 at 8:01

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much! That really helps! May I ask why it cannot click the xpath first to show the calendar? And if I would like to search for that date, I should click the search button, I try with driver.find_element_by_xpath("//*[@id='layui-laydate1']/div[3]/div/span").click() but it says no such element. May I ask for your advice

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.