tags:

views:

494

answers:

4

in a script when error comes i am just using "EXITGLOBALITERATION" command but its not going to the next iteration ....Is there any other alternative for this??

A: 

I'm not sure what you want. Have you tried On Error Resume Next? This will just carry on as if nothing happened. An alternative is plain On Error Resume which will retry whatever command failed.

VB Script doesn't have a command that lets you abort the current iteration in a loop and resume with the next one. To mimic this you'll have to use nested Ifs or Goto:

For i = 1 To 10
    ' … do something '
    If Not SomethingHappened Then
        ' … carry on '
    End If
Next i

The point here is pretty much to negate SomethingHappened so that the rest of the loop iteration only gets executed if your error condition did not occur.

Konrad Rudolph
No U didn't get me see when error occurs i want it to exit that iteration and go to next iteration.If there is no error it should continue to the next steps
A: 

You would have to test after each command for an error, something like this


On Error Resume Next
For i = 0 To 10
  'Command1
  If Err.Number = 0 Then
    'Command2
     If Err.Number = 0 Then
       'Command3
     End If
  End If
Next
Tester101
A: 

It looks like he is on about QTP!

I believe you should be using ExitActionIteration but without having an idea of the setup of your test script its hard to best know what you want.

Gigglymesh
+2  A: 

QTP's documentation has this to say about ExitGlobalIteration:

This statement is obsolete. Use the ExitTest Statement instead. The ExitTest statement supplies all the functionality of the ExitRun statement and is equally applicable for both QuickTest tests and Quality Center business process tests.

Motti