Print Page | Close Window

Scheduling Script Execution and Continuously run

Printed From: One Stop Testing
Category: Testing Tools @ OneStopTesting
Forum Name: QuickTest Pro @ OneStopTesting
Forum Discription: QuickTest Pro is a fresh approach to automated software and application testing that addresses testing needs of both business analysts and Quality Assurance professionals.
URL: http://forum.onestoptesting.com/forum_posts.asp?TID=7397
Printed Date: 18Nov2024 at 3:55pm


Topic: Scheduling Script Execution and Continuously run
Posted By: Mithi25
Subject: Scheduling Script Execution and Continuously run
Date Posted: 30Nov2009 at 11:12pm
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.


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

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True

qtApp.Open "C:\Tests\Test1", True ' Open the test in read-only mode. Include your driver script here.
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object

qtResultsOpt.ResultsLocation = "C:\Tests\Test1\Res1" ' Set the results location
qtTest.Run qtResultsOpt ' 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.

http://3.bp.blogspot.com/_MAr0lRJ3mPk/Sg52r5i7t5I/AAAAAAAAAOs/JrYlbnnTCQM/s1600-h/generatescript.JPG">

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.
http://3.bp.blogspot.com/_MAr0lRJ3mPk/Sg54gmr0NTI/AAAAAAAAAO0/G-2QfXcivcI/s1600-h/schdeuledTask.JPG">

- 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


-------------
http://www.quick2sms.com - Send Unlimited FREE SMS to Any Mobile Anywhere in INDIA,
Click Here



Print Page | Close Window