我试图当年和月匹配循环结束,但它不工作,我如何摆脱无限循环
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()
1条答案
按热度按时间6kkfgxo01#
尝试使用等于或等于:
而不是虽然真,你也可以否定的一部分,你用来打破,所以它会像虽然年和月不等于这样做的东西。