Tuesday 17 October 2017

Try...except not catching NoSuchElementException in python and selenium

I have this code
below:



def
test_counter(self):
try:
if
self.driver.find_element_by_id(self.counter).text ==
'texttexttext':

return True
except
NoSuchElementException and StaleElementReferenceException:

self.fix_error()
return
False


And I cannot
figure out why the NoSuchElementException or the
StaleElementReferenceException are not being caught.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...