I have created a test with 1 action which contains n actions. Is there any way to check after the execution of each action of the n actions the result if it is fail or pass and proceed accordingly?
1 Answers
Not directly.
A similar idea would be to ask for the current run result status, see How can I get the run result status according to the current report node?, but that is currently unsolved.
You can, however, call your actions, and consume there return value, like this:
ActionSucceeded=RunAction ("myTest [Action2]", oneIteration)
If not ActionSucceeded then
' The Action2 call signalled "failure" (false)
End If
This implies that Action2
must return such a result, like in here:
ExitActionIteration (false)
Beware, however, of the fact that RunAction
statements need to be inserted using QTP´s IDE (Insert/Call To Action...), resulting in a RunAction
call without brackets. When editing this to the assignment form above (with brackets), make sure you get it right the first time before you save the test -- because if you save a test containing a broken RunAction
call, QTP disassociates the called test, and the test will fail at runtime even if you edit the script back to correct syntax. This is due to metainfo that QTP saves invisibly in the script, and if you save an invalid action call, this metainfo is being discarded. (You can see when this happens because the action call will disappear from the test flow view.)
And: If you don´t store the RunAction
result in a variable, but use it directly, like in
If not RunAction ("myTest [Action2]", oneIteration) then
' The Action2 call signalled "failure" (false)
End If
the same mess arises: QTP does not understand that this is a valid action call, and it won´t work even if you edit it into back into the original form.
Except for the "beware" hint, the same holds true for LoadAndRunAction
, which calls an action at runtime. LoadAndRunAction
can be called as a function, and if the called actions returns a value via ExitActionIteration
, it returns that value.
Yet another "beware" hint: ExitActionIteration
really requires its arguments to be enclosed in brackets, even though it is a Sub
(or at least called as a Sub
). I suspect this is because it is not a real Sub
or Function
, but a special statement "patched into" the MS VBScript engine in some exotic way.

- 1
- 1

- 4,291
- 3
- 38
- 72
-
Oh, I am using QTP, but I think it´s the same in UFT. – TheBlastOne Dec 05 '14 at 14:12