Absent Member.
Absent Member.
1726 views

How to run the scheduler for QTP script

Jump to solution
Hi,
Can anyone please help me. I have my QTP script i want to run everyday at a set time.

Thanks
Rik
0 Likes
1 Solution

Accepted Solutions
Absent Member.. Absent Member..
Absent Member..
Hi Rik,

You can use "Scheduled Tasks" to launch QTP and run your script. Look under Start>Programs>Accessories>System Tools...

A command line like this should do the trick:
"C:\Program Files\HP\QuickTest Professional\bin\cmdrv" -usr "C:\Documents and Settings\Clark\Desktop\Examples and Corrections\Booo ya\Booo ya.usr"

Make sure you get right down to the ".usr" file.

Please post how it goes,
Thanks,
Ed

View solution in original post

0 Likes
7 Replies
Absent Member.. Absent Member..
Absent Member..
Hi Rik,

You can use "Scheduled Tasks" to launch QTP and run your script. Look under Start>Programs>Accessories>System Tools...

A command line like this should do the trick:
"C:\Program Files\HP\QuickTest Professional\bin\cmdrv" -usr "C:\Documents and Settings\Clark\Desktop\Examples and Corrections\Booo ya\Booo ya.usr"

Make sure you get right down to the ".usr" file.

Please post how it goes,
Thanks,
Ed

View solution in original post

0 Likes
Absent Member.. Absent Member..
Absent Member..
Hi..

Do you use TD for QC as well.?

If yes....then you can schedule the test runs from Test lab module.

Warm Regards,
Shivaram
0 Likes
Absent Member.
Absent Member.
Hi shivaram,
Actually we don't have QC & TD. So, actually i am trying to use windows scheduler to perform this task.

Thanks
Rik
0 Likes
Absent Member.
Absent Member.
Hi Ed,
Thanks for your response. actually i have tried running my script thru windows scheduler, But In the set time it is not able to open My QTP script. The error i am getting is browser error. like you said about the .usr file, should i use this in scheduler window. Can you please briefly explain about the command line which you had sent me.

Thanks
Rik
0 Likes
Absent Member.. Absent Member..
Absent Member..
Sure Rik. You can test the command line I sent at the CMD prompt. So, Start>Run, type "cmd" (no quotes) and click okay. At the black "CMD" window that appears you can paste the command. Of course you will want to verify the path on your machine for the first part (the "HP" might be might be "Mercury Interactive" for example) and you'll also need to modify the second part to indicate a ".usr" file from an existing script on your system.

So, once you validate that your whole command line works in that window, in theory you should be able to use it in the scheduler.

Here are some other things you can try:

Another method:
ExecuteTest "C:\TestOne"
ExecuteTest "C:\TestTwo"


Public Sub ExecuteTest(TestPath)

Dim qtpApp
Dim qtpTest

Set qtpApp = CreateObject("QuickTest.Application")

qtpApp.Open TestPath, True
Set qtpTest = qtpApp.Test
qtpTest.Run
While qtpTest.IsRunning
'Wait For Test To Finish
Wend
qtpTest.Close
Set qtpTest = Nothing
qtpApp.Quit
Set qtpApp = Nothing

End Sub


One more:
1. QTP 9.2 has the ability to generate the code to run QTP Script using command line automatically. For that Goto File > Setting and click on "Generate Script" button. and then save the script in a .vbs file.
Before running the .vbs file simple add the below two lines of code in it

App.Open "F:\QTPTests\Test3\" 'Specify appr. qtp test path
App.Test.Run ,True

2. For storing the QTP Test Results in your specified path, use the below code.

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")
qtResultsOpt.ResultsLocation = "C:\MyTest\Test1"
qtTest.Run qtResultsOpt

Hope one of the above works for you. Please post how it goes - and don't forget to assign points for helpful suggestions.
🙂
Ed
0 Likes
Absent Member.
Absent Member.
Hi Ed,
Thank you so much. I was able to run it. like the following. Now can i ask you another question? after my scheduler is running the test how can i see my test result.I really appreciate all of your help & being patience with me.
Thank
Rik
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\HP\QuickTest Professional\Tests\mytest", False 'Opens the test in editable mode
------
Dim Test_path
Test_path = "C:\Program Files\HP\Quicktest Professional\tests\mytest"
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
0 Likes
Absent Member.
Absent Member.
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\HP\QuickTest Professional\Tests\mytest", False 'Opens the test in editable mode
------
Dim Test_path
Test_path = "C:\Program Files\HP\Quicktest Professional\tests\mytest"
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
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.