Exit Statements in UFT – User friendly Tech help

Let us discuss various Exit statements which are quite useful in automation testing Using UFT.These statements are part of Vbscripting(Latest version) and when implanted in the code provides better control on the flow of execution of automated Tests.

n

It is also used in Error handling as and when some exception occurs we can use ‘Exit’ statements.

n

Syntax:-

n

    n

  1. Exit Do
  2. n

  3. Exit For
  4. n

  5. Exit Function
  6. n

  7. Exit Property
  8. n

  9. Exit Sub
  10. n

n

Detail:-

n

1.Exit Do, it is used to Exit a Do….Loop Statement. It transfers the control to the statement following the loop statement.

n

Example:-

n‘Code to Exit, when condition is meet
nDim iVar
niVar = 1
nDo
n    ‘Printing the value    Print iVarn

    ‘Incrementing the value

n
n    iVar = iVar +1
n    ‘Incase value is ‘5’ then exit do
n    If iVar = 5 Then
n        Print “Exit Do”
n        Exit Do
n    End If
nLoop while iVar

Was this article helpful?
YesNo

Similar Posts