python - Is there a way to rethrow Selenium error message? -


if wrap piece of selenium webdriver code "try except" in python, self.fail('some problem') in except block, don't know selenium have said @ point. if there had been no try-except, selenium gives error message, e.g visibility, or staleness of element, etc. how can webdriver program re-throw selenium error report ?

several options:

try:   ... except seleniumexception problem:   raise 

or

try:   ... except seleniumexception problem:   raise problem 

both re-throw original exception. first keep original stack (so can see selenium itself), latter handle exception if occurred not inside selenium @ point of raise.

but typically have new information @ point, might want add while keeping original stack trace , exception information. this, changing caught exception before rethrowing proposed; that's don't propose because isn't general approach. i'd rather stick following: python 3 knows exception chaining:

try:   ... except seleniumexception problem:   raise mynewexception("some additional information") problem 

and in case need more features or maybe on python 2, can have @ causedexception class. can used if need give more 1 cause (old exceptions) new exception.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -