How to enter datetime values in python selenium datepicker?



I have the page to enter datetime, I have the datetime value as string, I am passing that to through the find_element_by_xpath, I am getting error
This is my xpath

enter image description here

I have the value in string variable

value = '1980-06-30T00:00:00Z'

I use the code

xpath = '//*[@id="main-panel"]/div/app-manual-update/div/div/form/div[36]/div/input'

I get

ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=94.0.4606.61)

![enter image description here

How to pass the datetime value?


You need to use JS, like below :

from datetime import datetime
today_date ='%Y-%m-%d')

wait = WebDriverWait(driver, 30)
date= wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id="main-panel"]/div/app-manual-update/div/div/form/div[36]/div/input")))
driver.execute_script(f"arguments[0].setAttribute('value', '2021-06-30T00:00:00Z')", date)

Imports :

from import WebDriverWait
from import By
from import expected_conditions as EC

Date format is yyyy-mm-dd also make sure to not click on date picker, it will directly input the values in input field.

Answered By – cruisepandey

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More