Skip to content Skip to sidebar Skip to footer

Calendar Date Picker Selenium Python

Hi I am trying to figure out how to do date picking on the calendar for zacks for some personal project. unable to figure out how that works. I read a post on datepickers being use

Solution 1:

To select the date 12/1/2020 within the website https://www.zacks.com/earnings/earnings-calendar you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    driver.get('https://www.zacks.com/earnings/earnings-calendar')
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a#date_select img"))).click()
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "table.sb_minicalview td > span#dt_1"))).click()
    
  • Using XPATH:

    driver.get('https://www.zacks.com/earnings/earnings-calendar')
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@id='date_select']/img"))).click()
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//table[@class='sb_minicalview']//td/span[@id='dt_1']"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.uiimportWebDriverWaitfrom selenium.webdriver.common.byimportByfrom selenium.webdriver.supportimport expected_conditions asEC
  • Browser Snapshot:

zacks_datepicker


References

You can find a couple of relevant detailed discussion in:

Post a Comment for "Calendar Date Picker Selenium Python"