Results 1 to 3 of 3
  1. #1

    Exit out of the script

    The scenario is: We have a script in QTP which will iterate for all rows in the datatable.

    If there are some error in the first iteration, I would like all the browsers opened for that iteration to be closed and start fresh for the next iteration or completely exit out of the script. We are using ExitAction in our scripts and it exits out of the iteration not the script and doesnot close all the browsers. We have used “Close all browsers” option in the tools-> options-> Web, but this will close all the browsers only after the test ends.

    We don't want to use ExitRun in our scripts since it causes other complications.

    What is your take on this? I am using QTP 6.5.

  2. #2

    Re: Exit out of the script

    Here is function to close all open browsers..

    Function fnCloseProcessByName(strProcessName)

    On Error Resume Next

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = '" & strProcessName & "'")

    For Each objProcess in colProcessList

    End Function

    You can call this function anytime in your script, give IEXPLORE.EXE to close IE.

  3. #3

    Re: Exit out of the script

    another method would be to use the command:


    just before you do your ExitAction command.
    I'm not a complete idiot - some parts are missing.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:38 PM.

Copyright BetaSoft Inc.