How do you find where a custom Exception is defined so that you can import it. In my stacktrace of an error that is thrown in my code I am getting a NoSuchElementException. I would like to catch this specific exception but I can't find where to import it from. Is there a way to determine what to import from the stacktrace?
Traceback (most recent call last):
File "/home/ubuntu/webapps/tablecloth/src/tablecloth/apps/atsa/adaptor.py", line 266, in login
welcome_field = driver.find_element_by_class_name(self.welcome_id)
File "/home/ubuntu/webapps/tablecloth/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 342, in find_element_by_class_name
return self.find_element(by=By.CLASS_NAME, value=name)
File "/home/ubuntu/webapps/tablecloth/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 680, in find_element
{'using': by, 'value': value})['value']
File "/home/ubuntu/webapps/tablecloth/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 165, in execute
self.error_handler.check_response(response)
File "/home/ubuntu/webapps/tablecloth/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 158, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: u'Unable to locate element: {"method":"class name","selector":"userName"}' ; Stacktrace:
at FirefoxDriver.prototype.findElementInternal_
Catch the exception with Exception so that you have access to the exception object:
try:
call_your_function()
except Exception as e:
print e.__module__
Then replace Exception with the more specific one you find out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With