I'm trying to "try" clicking a number of URLs before refreshing the page and trying again.
But when the first one doesn't work, it will go straight to the "except" clause.
Is there a way to rewrite my loop so that it tries the whole list first, please?
(currently it will try value 12, then refresh and try value 12 again)
Code: Select all
preferred_times = ['12', '13', '14']
for pt in preferred_times:
try:
find_element_by_xpath("//html/[1]/tbody/[" + pt + "]/td[2]/tfont").click()
except:
driver.refresh()