How To Run QTP Scripts at Scheduled Time? | Quick Test Professional(QTP)
.

How To Run QTP Scripts at Scheduled Time?

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
image
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"
image
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. image











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: ,,,,

20 comments:

bchik said...

Excellent! Thanks for the detailed steps.

DhilipR said...

Thank u!! excelnt work

Anonymous said...

It is still a question how to launch the QTP scripts? .VBS file script only open QTP.

Anonymous said...

I have the same question. wanna run the scripts completely unattended. otherwise no point opening a scripts as a scheduled task.

Maniz said...

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

Anonymous said...

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.

megha said...

The 4th step:
App.WindowState = "Maximized
is redundant as making this step as commented also opens the application in maximized window.

Patrick said...

Maniz & Ankur

Thanks you for this! This is realy cool!

Cheers from Switzerland
Patrick

Anonymous said...

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

Niranjan said...

How do you take care, if the machine is in locked mode at the specified time?

Ankur said...

@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.

Anonymous said...

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!!!!!!!!!!

Anonymous said...

Same query from me guys - How to set QTP to send the result via email automatically? Vijay.

Siddhesh said...

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?

abhishek said...

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

Soujanya said...

@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

Anonymous said...

Can we do this for the more than scripts?

Rahul Dravid said...

How to send test results in qtp to an excel file.

vk said...

Datatable.ExportSheet" path to your storage location"

Vk said...

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.