There can be situations when you need to schedule your QTP scripts so that they can run when you are not present in front of your PC. I will show you a demo below.
1) Create a .vbs file to launch QTP with required settings, add-ins etc.
Here is a sample vbs code
Set App = CreateObject("QuickTest.Application") App.Launch App.Visible = True App.WindowState = "Maximized" ' Maximize the QuickTest window App.ActivateView "ExpertView" ' Display the Expert View App.open "C:\Program Files\Mercury Interactive \QuickTest Professional\Tests\Test1", False 'Opens the test in editable mode
2) ok, for the first timers. Create a sample QTP test and save it as Test1 at the location above. Copy the code into notepad and name the file as testing.vbs 3) Now we will automate the opening of vbs file through Windows Scheduler. Go To Start > Control Panel > Schedule Tasks > Click Add Schedule Tasks Click Next on the screen.
4) Click Browse and and select the .vbs file you just created.You will get this screen
5) Give a name to the task and select the frequency for performing the given tasks. For this demo we will select "One time only"
6) Select Start Time and Start Date. For this demo, select Start Time as current time+5 mins and Start date as todays date.
7) Next Screen Enter "UserName", "Password" and "Confirm Password" Click Next and you should get this screen.
8) Click on Finish and yay, you're done.
Note: The steps above are for Windows XP and may be different for other Operating Systems.
Let me know through the comments below, your views on it.
If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS Feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.
Technorati Tags: automatic,launch,QTP scripts,schedule,Windows Scheduler

32 comments:
Excellent! Thanks for the detailed steps.
Thank u!! excelnt work
It is still a question how to launch the QTP scripts? .VBS file script only open QTP.
I have the same question. wanna run the scripts completely unattended. otherwise no point opening a scripts as a scheduled task.
Dim Test_path
Test_path = "C:\Documents and Settings\MKrisha\Desktop\Automation\Streamline_Regression_Suites"
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
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.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False
qtApp.Open Test_path, True ' Open the test in read-only mode
' set run settings for the test
Set qtTest = qtApp.Test
qtTest.Run ' Run the test
qtTest.Close ' Close the test
qtApp.quit
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object
Thanks for the inputs. But this is useful only when the scriot mentioned here runs on its own and does not require any user input or a click.
The 4th step:
App.WindowState = "Maximized
is redundant as making this step as commented also opens the application in maximized window.
Maniz & Ankur
Thanks you for this! This is realy cool!
Cheers from Switzerland
Patrick
Hi
I have followed the step by step procedure for scheduling tasks thru scheduler in Control Panel.
im getting an error message for it...System is not opening the .vbs file which has the code.
Pls help as I am working on something similar. As already mentioned .vbs is opened ony thru QTP?
Please Clarify
How do you take care, if the machine is in locked mode at the specified time?
@Niranjan: Nice Q...You can try this[ http://www.softtreetech.com/24x7/archive/51.htm ] to unlock a computer through scripting.
Since I haven't used this myself so please let me know how it worked for you.
How can we email our qtp test results to outlook email?
Ankur,
I would really appreciate if you can tell us how we can email the qtp test results to outlook emails.....thanks!!!!!!!!!!
Same query from me guys - How to set QTP to send the result via email automatically? Vijay.
hi,
Thanks for your inputs on how to open the test in QTP from vbs.. but now my question is how to pass parameters to perticular action?
Hi Friends,
I tried the above code to run the QTP application according to scheduled task but i can't see the test results after end of test can someone help on that how to get tese results after the successful execution of the test through above code.
Thanks
Abhishek Sharma
@Abhishek
Try to see where the Test Results are generally saved for your tests in QTP when you open QTP normally (You can verify this but clicking on the Run button in the QTP and you will get a window asking where to store your Test Results) that may help you find the test results when they are run using automated script.
Let me know if you tried some other way.
Hope this helped.
Soujanya
Can we do this for the more than scripts?
How to send test results in qtp to an excel file.
1. can we do this for multiple scripts?
2. Do we need a VBS editor or VB editor to open this, because i got an error at the scheduled time.
Datatable.ExportSheet" path to your storage location"
But if we want to do this on QCServer what should we do?
I tried to launch the application by using .vbs script but its giving an error access is denied even while creating the scheduled task and that's why my .vbs script never runs and error saying "......access is denied....."displayed. Is there any solution to this problem.
i tried with above example ,it just open the script but not executed the script.is there any thing i have to add in the script t\for execution of the script.Kindly let me know the solution
How do i save the results to Quality Center?
I have used the below lines of code (vbs file)to open and run the script. I was able to successfully save the results in the location as mentioned in a local directory.
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible
Set qtResultsObj = CreateObject("QuickTest.RunResultsOptions")
qtApp.Open "[QualityCenter] Subject\Infrastructure\Automation Test\launchscript", True ' Open the test in read-only mode
Set qtTest = qtApp.Test 'set run settings for the test
qtResultsObj.ResultsLocation = "C:\Documents and Settings\Pganta\QTPresults" ' Set the results location
qtTest.Run ' Run the test
qtTest.Close ' Close the test
qtApp.quit
set qtResultsObj = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object
Thank you. this article helped me to solve the problem
To run multiple scripts: simply create a master script and call all the scripts that u need to execute...now give the path of the master script in the vbs file....
I got the Task Scheduler to work. I am in need of the send mail function. I want to add a send mail function to notify me via when QTP detect error during testing/validation. I want to have email message like: "Error encounter. Unable to proceed. Please check error".
Thanks in advance.
I followed same steps but am not able to read data from excel..it only runs the scripts
This is superb! thanks a ton Ankur and Priyaranjan.
Thanks the solution is really good
How to invoke QTP using mail
hi...
i am using qtp 9.5 ,in my product some applications are getting recorded but applications (like sfs or lookup ahead) not geeting recorded.plz give some suggestions.
gouse
Post a Comment