I have a code where it looks for a name and I am trying to write an if statement that says if it can't find that name look for something else.
What I have so far is as follows:
excel = driver.find_element_by_name("Export to Excel")
if excel == None:
driver.implicitly_wait(15)
search = driver.find_element_by_xpath("//span[@id='inplaceSearchDiv_WPQ2_lsimgspan']")
search.send_keys('testing')
else:
excel.click()
I know what's inside the if statement works because I tested it out. Am I suppoed to change my argument in my if statement? The error I get is selenium.common.exceptions.NoSuchElementException: Message: No such element I tried entering "No such element" instead of "None" but I still get the same error. Also it tells me Exception Unhandled NoSuchElementException('No such element', None, None) can some give me advise on what I am doing wrong with the if statement?
Aucun commentaire:
Enregistrer un commentaire