Micro Focus QTP (UFT) Forums
Run QTP Test using VBscript - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Run QTP Test using VBscript (/Thread-Run-QTP-Test-using-VBscript)



Run QTP Test using VBscript - riteshgpt - 04-08-2010

Hi I am using QTP to test windows application.
I have created test1 with 10 action action1 , action2 .. action 10

Now I am running test using VB script.
By default its start with Action1.

however I want to run action order specify by me on the fly using vbscript.

Some times I want to run Action 2 and Action 10 and some time Action 1 and Action 10 like that its depend of condition.

here is my vbscript

Code:
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtOptions 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
Set qtApp = CreateObject("QuickTest.Application") ' Create a Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible



' Set QuickTest run options
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"

qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = True




' Open the test
qtApp.Open "C:\Tests\Test1\Test1", False ' Open a test named "Test1"

Set qtOptions = CreateObject("QuickTest.RunResultsOptions") ' Create a Results Option object
qtOptions.ResultsLocation = "C:\Tests\Results\" ' Set the Results location to temporary location

' set run settings for the test
Set qtTest = qtApp.Test
'qtTest.Settings.Run.IterationMode = "rngIterations" ' Run only iterations 2 to 4
'qtTest.Settings.Run.StartIteration = 1
'qtTest.Settings.Run.EndIteration = 1
qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs

[i]'  [u]qtTest.RunAction "Action1",oneIteration[/u] I need some thing like this. but dont know how to use.[/i]

qtApp.Test.Run qtOptions, True ' Run the test and wait for it to finish before continuing the automation script


qtApp.Test.Save ' Save the test

qtApp.Quit ' Exit QuickTest
Set qtOptions = Nothing ' Release the Run Results Options object
Set qtApp = Nothing ' Release the Application object



RE: Run QTP Test using VBscript - Saket - 04-09-2010

You cant do the way you mentioned in your vbs. the vbs will help you open the test not the action which are associated with your test.
one of the way could be write some more code in your test to run an action based on certain condition on input to the test.
you can pass the input parameter to the test from vbs and then in your test you can decide which action to run.


RE: Run QTP Test using VBscript - riteshgpt - 04-09-2010

Hi Saket thanks for response.
can you please provide some sample for same, if it is possible.