If you want to start an UFT test from the command line. First I thought it was simple, like most of the tools I use and just enter the following command:
C:\Program Files (x86)\HP\QuickTestPro\bin\QTPro.exe "C:\SomeTest\"
But I was wrong. I needed to create a vbs script to start a test from command line. Why from command line? Because if I wanted to start it automatically via a scheduler, a command line is needed. I found a script on stackoverflow that I adapted a little bit to my needs.
'******************************************************************* 'runtest.vbs testResourcePath = "C:\tests\Output" 'Getting the test path Dim objArgs Set objArgs = wscript.Arguments testPath = objArgs(0) 'Determining that the test does exist Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") DoesFolderExist = objFSO.FolderExists(testPath) Set objFSO = Nothing If DoesFolderExist Then Dim qtApp 'Declare the Application object variable Dim qtTest 'Declare a Test object variable Dim qtResultsOpt Set qtApp = CreateObject("QuickTest.Application") 'Create the Application object qtApp.Launch 'Start QuickTest qtApp.Visible = True 'Make the QuickTest application visible qtApp.Open testPath, False 'Open the test in read-only mode Set qtTest = qtApp.Test Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object qtResultsOpt.ResultsLocation = testResourcePath ' Specify the location to save the test results. qtTest.Run qtResultsOpt,True 'Run the test and wait until end of the test run qtTest.Close 'Close the test qtApp.Quit Else 'Couldn't find the test folder. We have to report on how we couldn't find the test. End If
I really do not understand why such an expensive tool like UFT has no command line mode. Fortunately it works like this too.