0% found this document useful (1 vote)
4K views

Driver Script To Run Multiple QTP Scripts

This document provides a sample driver script to run multiple QuickTest Professional (QTP) test scripts. It describes defining environment variables to specify the test flow and minimum and maximum actions. The main action code uses a do loop to iterate through the actions, running each one if it is between the minimum and maximum values and breaking out of the loop if an action returns true. It also describes an alternative approach of defining an environment variable for each action to specify whether to run it or not. The document provides an example VBScript to launch QTP, connect to a Quality Center project, open and run multiple tests, and close QTP.

Uploaded by

api-19840982
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
4K views

Driver Script To Run Multiple QTP Scripts

This document provides a sample driver script to run multiple QuickTest Professional (QTP) test scripts. It describes defining environment variables to specify the test flow and minimum and maximum actions. The main action code uses a do loop to iterate through the actions, running each one if it is between the minimum and maximum values and breaking out of the loop if an action returns true. It also describes an alternative approach of defining an environment variable for each action to specify whether to run it or not. The document provides an example VBScript to launch QTP, connect to a Quality Center project, open and run multiple tests, and close QTP.

Uploaded by

api-19840982
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Sample of Driver script to run multiple QTP scripts

Hi,

If you just wish to control the execution of QTP Actions, you don't need anything
special.

I'll describe a simple way of achieving your goal with really minimum development
effort.

1) Let's agree that your QTP test is a script that should run a sequence of actions.
Each action can be a test on its own, or really a part of a more complex test.

2) In such a case:
a) Your main action (e.g., Action1) would contain the code as shown below.
b) Define environment variables as required:
TEST_FLOW
MIN_ACTION
MAX_ACTION
You can define these in the test or in an external xml file to be loaded at run-time
with:

Code
GeSHi (qtp):
Environment.Load(<Pathname>)

Created by GeSHI 1.0.7.20

Main Action code


Code
GeSHi (qtp):
Dim arrActions, blnBreak, intMinAction, intMaxAction, intCurAction

arrActions = split(Environment("TEST_FLOW"), ";")

'Remark: The TEST_FLOW environment variable would contain a concatenated string


with the actions names separated by ; (semicolon). For example: "Login;Create
Customer;Create Account;Activate Account;Create Service Package;Logout"

blnBreak = False

intCurAction = 0

intMinAction = Environment("MIN_ACTION") 'MIN_ACTION would contain an integer


with the first action to run in the flow (default=1).
If (intMinAction = 0 Or intMinAction = "") Then

intMinAction = LBound(arrActions) 'Default

End If

intMaxAction = Environment("MAX_ACTION")

If (intMaxAction = 0 Or intMaxAction = "") Then

intMaxAction = UBound(arrActions) 'Default

End If

intCurAction = intMinAction

Do

blnBreak = RunAction arrActions(intCurAction) 'it's also possible to build it with the


other parameters such as number of iterations, etc.

intCurAction = intCurAction+1

Loop Until (blnBreak Or intCurAction > intMaxAction)

Created by GeSHI 1.0.7.20

Another approach (as you suggested) is to define per action whether to run it or not.
Please note that this requires that the actions ARE NOT functionally dependent.

You can achieve this by defining an environment variable for each to-be-run action
(e.g., Create Service Package) and assigning it a value of, for instance, Y/N.
Then your loop code would change to:
Code
GeSHi (qtp):
Do

If (Environment(arrActions(intCurAction)) = "Y") Then

blnBreak = RunAction arrActions(intCurAction)

End If

intCurAction = intCurAction+1

Loop Until (blnBreak Or intCurAction > intMaxAction)


2.Running QTP Scripts from QC

Give a try with this code from vbs file. It might work.

Public Function testFunc()


Set qtApp = CreateObject("QuickTest.Application")

qtApp.Launch

qtApp.Visible = False

If Not(qtApp.TDConnection.IsConnected) Then
qtApp.TDConnection.Connect "http://xxxxxxxxx/qcbin","Domain", "Project", "uid",
"pwd", False

End If

qtApp.Open "[QualityCenter] Subject\Automation\Test1", False

qtApp.Test.Run

qtApp.Open "[QualityCenter] Subject\Automation\Test2", False

qtApp.Test.Run

qtApp.Open "[QualityCenter] Subject\Automation\Test3", False

qtApp.Test.Run

qtApp.quit

Set qtApp = Nothing

End Function

Call testFunc()

You might also like