0

guys I need your assistance.

I have the next HTML page enter image description here

I need to write a code to check today's date and automatically click on the next day in the calendar enter image description here

currently, this is the code I'm using

driver.implicitly_wait(5)
click_on_date_option=driver.find_element(By.ID,'input_27').click()
time.sleep(3)
date_calender=driver.find_element(By.XPATH,'//*[@id="input_60"]').click()
time.sleep(3)
driver.implicitly_wait(5)
select_today_first=driver.find_element(By.CSS_SELECTOR,'button.dtp-btn-today.md-button.md-button.ng-scope.md-ink-ripple').click()
time.sleep(3)
driver.implicitly_wait(5)
next_day=select_today_first,1
click_next_day=driver.find_element(next_day).click()
click_ok=driver.find_element(By.CSS_SELECTOR,'button.dtp-btn-ok.md-button.md-button.md-ink-ripple').click()

time.sleep(3)
driver.implicitly_wait(5)

1 Answers1

0
import datetime
tomorrow = datetime.datetime.now() + datetime.timedelta(days=1)
date = 'date-'+tomorrow.strftime('%y-%m-%d')
driver.find_element(By.XPATH,f"//a[@id='{date}']").click()

You can use datetime to get next day and then get the a id with that element.

Try using this for that error:

from datetime import datetime as dt, timedelta
tomorrow = dt.now() + timedelta(days=1)
date = 'date-'+tomorrow.strftime('%y-%m-%d')
Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32