i tried to when year and month match loop end but it not works, how i get rid of infinite loop
driver.switch_to.frame(0)
month = "March"
year = 2023
driver.find_element(By.XPATH, "//input[@id='datepicker']").click()
while True:
mon = driver.find_element(By.XPATH, "//span[@class='ui-datepicker-month']").text
yr = driver.find_element(By.XPATH, "//span[@class='ui-datepicker-year']").text
print(mon, yr)
if mon == month and yr == year:
break
else:
driver.find_element(By.XPATH, "//*[@id='ui-datepicker-div']/div/a[2]/span").click()
Try using equals or is:
mon.__eq__(month) and yr.__eq__(year)
Instead of while true you can also negate the part that you use for breaking so it will be like while year and month not equal to something do this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.