12-05-2013 09:04 PM - edited 12-05-2013 09:27 PM
Today i experienced that "ExitActionIteration" does not work in the function when "On Error resume Next" is used.
(This only happens when functions are kept in a library files. If function is written in the calling action then 'ExitActionIteration' is working fine).
We are usually keep our functions in library files, where in some conditions we need to exit the ActionIterations, but in this case we are unable to do that and our tests keep running even in failure scenarios.
Currently i am using UFT11.52, but i believe that this issue should persists in previous versions of QTP also.
Please tell if this is an expected behaviour? If yes then please let us know how can we exit the iteration from a function where "On error Resume next" is used (and the function is written in external/library file) ?
Note: I could find the solution where i am using "ON error goto 0" before "ExitActionIteation" , and whoa it worked :-) .
Is there any second thought on this?
Call FuncA 'Keep this code in the calling Actions
'Following Functions should be kept in a library files.
print "FUNC A CALLED"
On Error Resume Next
print "FUNC B CALLED"
'On Error goto 0
On Error goto 0
print "FUNC C CALLED"
Solved! Go to Solution.
12-06-2013 03:07 AM
This is happening because statements like
ExitAction, ExitActionIteration, ExitTest, ExitTestIteretion raise (internal) run-time errors in QTP/UFT.
Those run-time errors are catched by the On Error Resume Next statement, which enables the error handling, and therefore execution continues with next statement - in this case, the Call funcC line. This is the expected behavior of On Error Resume Next statement and you "turn it off" with the On Error Go To 0 statement.
If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.”