I want my bot to check all the 12 months till given yearly range if any date available between today to till end of the range bot should mention the date.
Here is my code
dd = driver.find_element(By.ID, ("ui-datepicker-div"))
current_month = driver.find_element(By.CLASS_NAME, "ui-datepicker-month").text
current_year = driver.find_element(By.CLASS_NAME, "ui-datepicker-year").text
while not (current_month.__eq__("April") and current_year.__eq__("2025")):
driver.find_element(By.XPATH, "//span[text()='Next']").click()
current_month = driver.find_element(By.CLASS_NAME, "ui-datepicker-month").text
current_year = driver.find_element(By.CLASS_NAME, "ui-datepicker-year").text
print(current_month, current_year)
dd = driver.find_element(By.XPATH, "//td[@data-handler='selectDay'][@data-event='click']").click()
paragraph3 = driver.find_element(By.XPATH, "//td[@data-handler='selectDay'][@data-event='click']").get_attribute(
"textContent")
print(paragraph3)
d = "{} {} {}".format(current_year, current_month,paragraph3)
print(d)
# Find an element by its ID
element = driver.find_element(By.ID, 'appointments_consulate_appointment_date')
# Get text content of element
text_content = element.text
print(text_content)
time.sleep(5)
# Close the driver
driver.quit()
In this code bot only show April 2025 dates and if April don’t have any available date then bot picks may date.
I am getting confused in looping system, my bot just checking dates in given year of month not checking all months till the end of the range.