2

I have a conflicting situation while testing a web app through python selenium. I get unexpected Error pop up windows (usually javascript errors). This can occur at any event of my test flow, I can handle the exceptions but the problem lies when returning back to the program flow after handling the exception.

For example:

class MyError:
    def ErrorHandled(self):
        print 'something'

try:
    Line 1
    Line2
    Line3
    Line4
except MyError:
    pass

My issue here is while running the try block flow of statements; the MyError can occur anytime and any number of times. But it is not suppose to stop the execution of the code when it catches the Exception, I want it to resume back to the try statement.

If the Exception occurs after Line 2 and Line 3, the try block must be resumed to Line 4 and stop the execution of the code only when the try block completes its flow. How can I do this ?

Bharath Kashyap
  • 343
  • 2
  • 5
  • 14
  • 1
    Have you tried to use the finally feature? [Why do we need the “finally” statement in Python?](http://stackoverflow.com/questions/11551996/why-do-we-need-the-finally-statement-in-python) – omri_saadon Dec 21 '16 at 07:29
  • "finally" will not help me out here. it is used when there is a situation like for ex: executing finally statements irrespective of the results thrown by try or except block statements. – Bharath Kashyap Dec 24 '16 at 19:58
  • I tried something similar to the OP here, but not able to get to the result. Here is my code... – Bharath Kashyap Dec 24 '16 at 20:00

0 Answers0