Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
How to interact with Ant Design calendar from Selenium?

I have an app using a calendar from Ant Design.

The date picker seems to be a read only attribute. I need to interact with this element from Selenium in Python.

To get around it, I tried the following code:

self.driver.execute_script("document.querySelector('.ant-calendar-picker-input.ant-input').readOnly = false")
self.driver.execute_script("document.querySelector('.ant-calendar-picker-input.ant-input').value ='12-12-2021'")
self.driver.execute_script("document.querySelector('.ant-calendar-picker-input.ant-input').readOnly = true")

With this code the date does not get updated (it does change on the UI, but the date HTML attribute is empty). What am I doing wrong?

Here are screenshots of the HTML code: enter image description here After the date gets updated (manually): enter image description here

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda