Home > database >  How to interact with Ant Design calendar from Selenium?
How to interact with Ant Design calendar from Selenium?

Time:09-23

I have an app using a calendar from enter image description here After the date gets updated (manually): enter image description here

Thanks

CodePudding user response:

Based on the HTML that you've shared, I would advise you to use the below code to update the date picker field, you do not need to click in date picker at all, just run the below JS code.

wait = WebDriverWait(driver, 20)
date_to_fill = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "span#codigo_fecha_vencimiento input.ant-calendar-picker-input.ant-input")))
driver.execute_script("arguments[0].setAttribute('value', '15-09-2021')", date_to_fill)

Imports :

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