0

I am trying select date with date no. url:http://www.szse.cn/disclosure/bond/notice/index.html I am trying: for the start month & date,

wait.until(EC.element_to_be_clickable((By.XPATH, "//ul[@class='monthselect'][1]//li[text()='{}']".format("1")))).click()
wait.until(EC.element_to_be_clickable((By.XPATH, "(//table[@class='table-condensed'])[1]//tbody/div[@class='tdcontainer' and contains(text()='15')]"))).click()

I can go with like tr[2]//td[3] but I want just use the date no. like 1,2,3..

Many thanks!!

1 Answer 1

1

I did it by typing the date, not by using the datepicker. In my experience, this is the more reliable way.

import time
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

def run():
    driver = webdriver.Chrome(executable_path="C:\Windows\chromedriver.exe")

    driver.get('http://www.szse.cn/disclosure/bond/notice/index.html')

    wait = WebDriverWait(driver, 10, poll_frequency=1)
    element = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "input-left")))

    s1 = driver.find_element_by_class_name('input-left')
    s1.send_keys("2021-03-03")

    s2 = driver.find_element_by_class_name('input-right')
    s2.send_keys("2021-03-04")

    s3 = driver.find_element_by_id("query-btn")
    s3.click()

    time.sleep(5)

if __name__ == '__main__':
    run()
Sign up to request clarification or add additional context in comments.

3 Comments

Hi, thanks for your help! you just give me another way to deal with datepicker, many thanks! but may I ask if any datepicker can be sent keys or just some with input?
You're welcome! I've dealt with some Kendo UI for jQuery datepickers and sending keys to their input worked too.
That's been my experience too. Different date pickers work in different ways, so you need to treat them individually to figure out how to interact with them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.