elem = browser.find_element_by_xpath(".//label[@class = 'checkbox' and contains(.,'Últimos 15 días')]/input")
if ( elem.is_selected() ):
print "already selected"
else:
elem.click()
In my code elem.click()
gets gives an error sometimes. If it does, I need to call elem = browser.find_element_by_xpath
again i.e. the first line of the code.
Is there a way to achieve this using exception handling in python. Help will be much appreciated.