Micro Focus QTP (UFT) Forums
VBS to launch QTP 9.2 and invoke script automatically - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: VBS to launch QTP 9.2 and invoke script automatically (/Thread-VBS-to-launch-QTP-9-2-and-invoke-script-automatically)



VBS to launch QTP 9.2 and invoke script automatically - test123 - 04-10-2008

Hi,
I need a VBS Script to launch QTP 9.2 and invoke the driver script automatically.....
Can you please help me with this?


RE: VBS to launch QTP 9.2 and invoke script automatically - lucky.qa - 04-10-2008

************************************************************************************************************************

'Description:

'

'This example configures QuickTest views and panes for running QuickTest in visible mode.

'************************************************************************************************************************



Code:
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

qtApp.Launch ' Start QuickTest





qtApp.ActivateView "ExpertView" ' Display the Expert View

qtApp.ShowPaneScreen "ActiveScreen", True ' Display the Active Screen pane

qtApp.ShowPaneScreen "DataTable", False ' Hide the Data Table pane

qtApp.ShowPaneScreen "DebugViewer", True ' Display the Debug Viewer pane

qtApp.WindowState = "Maximized" ' Maximize the QuickTest window

qtApp.Visible = True ' Make the QuickTest window visible



Set qtApp = Nothing ' Release the Application object





--------------------------------------------------------------------------------


RE: VBS to launch QTP 9.2 and invoke script automatically - Sri - 05-08-2008

The following VBScript works for me:

Enter the following code in VBScript editor and save teh file(saves as a VBS file) then you can go to the CMD to run the VBS file or use windows scheduler to schedule for a particular time.This is just an example make sure to change the location of the test script.

'**************************************************************************
'The following script opens a test, configures run options and settings,
'runs the test, and then checks the results of the test run.
'**************************************************************************
Code:
Dim qtApp 'As QuickTest.Application 'Declare the Application object variable
Dim qtTest 'As QuickTest.Test 'Declare a Test object variable
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
Const ForReading = 1, ForWriting = 2
Dim fso, f, result

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\Regression_Test_Results.txt", ForWriting, True)

Set qtApp = CreateObject("QuickTest.Application") 'Create the 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 = False
qtApp.Open "C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\Regression_Suite_BA_1\CharitableOrg_Owner_NonQual_GuaDeathBenefit_SurrenderCharges", True ' Open the test in read-only mode

'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 = 2
qtTest.Settings.Run.EndIteration = 4
qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs

'Set the results path
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
qtResultsOpt.ResultsLocation = "C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\Regression_Suite_BA_1\CharitableOrg_Owner_NonQual_GuaDeathBenefit_SurrenderCharges\Res1" ' Set the results location
qtTest.Run qtResultsOpt 'Run the test
result= qtTest.LastRunResults.Status
f.Write("Test 1: CharitableOrg_Owner_NonQual_GuaDeathBenefit_SurrenderCharges - ")
f.Write(result)
f.WriteBlankLines(1)