P. 1
Driver Script to Run Multiple QTP Scripts

Driver Script to Run Multiple QTP Scripts

|Views: 227|Likes:
Published by Ramu Palanki

More info:

Published by: Ramu Palanki on Dec 29, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as RTF, PDF, TXT or read online from Scribd
See more
See less

11/20/2014

pdf

text

original

For QTP Realtime Scripts, visit www.ramupalanki.

com
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).

For QTP Realtime Scripts, visit www.ramupalanki.com
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)

For QTP Realtime Scripts, visit www.ramupalanki.com
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're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->