Once after successfully completing dry run of QTP scripts there is no need to monitor the script execution.
We can schedule the script execution during night time also.
Scheduling can be done easily using window task scheduler for starting the execution of QTP script automatically at a predefined time.
For doing scheduling, we need to create .vbs file.
The Important steps required for scheduling are,
– Create a Driver script which calls all the scripts one by one.
– Complete Dry run to make sure script will continue execution without any interruption. Add Recovery scenario for handling any unexpected pop-up window or any other inconsistent behavior of the application under test.
– Create a .vbs file which will be used for starting the QTP using Automation Object Model. Remember to add the code for keeping settings/options of the QTP so that the scheduler will open QTP with same settings.
you can refer the below sample vbscript code for creating the .vbs file to be called from the scheduler.
‘Declare the Application object variable
Dim qtApp As QuickTest.Application
‘Declare a Test object variable
Dim qtTest As QuickTest.Test
‘ Declare a Run Results Options object variable
Dim qtResultsOpt As QuickTest.RunResultsOptions
‘ Create the Application object
Set qtApp = CreateObject(“QuickTest.Application”)
‘ Start QuickTest
qtApp.Visible = True
‘Open the test in read-only mode. Include your driver script here.
qtApp.Open “C:\Tests\Test1”, True
‘ Create the Run Results Options object
Set qtResultsOpt = CreateObject(“QuickTest.RunResultsOptions”)
‘ Set the results location
qtResultsOpt.ResultsLocation = “C:\Tests\Test1\Res1”
‘ Run the test
The complete code and details can be found in the QTP help file for Automation Object Model.The next step is we should merge the code for QTP options/settings within this code.The options/settings code can be easily generated automatically.
Click Tools->Options from QTP IDE to open the below screen.
Click “generate” in the above screen to automatically generate the code.
– Then add a task in windows scheduler for calling the .vbs file.
You can do it by using Schedule Task wizard from settings->control panel->Scheduled Tasks->Add Scheduled Task
Click “Browse” in the below screen of the wizard to set specify your .vbs file.
– Locking the system while running the script will affect the script running.So don’t lock your machine while running the script. Anyway, you can add the below code at end of your .vbs file to lock the system automatically once after completing execution of the script.
Set obj = CreateObject("WScript.Shell") sCmnd = "%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation" obj.Run sCmnd, 0, False