Search code examples
batch-fileqtphp-uft

Launching UFT ( QTP ) Tests remotely through a batch file.


I have created a bunch of UFT 12 (ex QTP) tests and I have also created a batch file in order to run theses tests.

When I run the batch file in local the tests are running fine.

Here is the script I use :

 Set qtpApp = CreateObject("QuickTest.Application")
 Set fsObj = CreateObject("Scripting.FileSystemObject")
 Set qtpResObj = CreateObject ("QuickTest.RunResultsOptions")

qtpApp.Launch
qtpApp.Visible= true

sfolderPath = "C:\QA\ManagerForOracleDB"
Set mainFolderObj = fsObj.GetFolder (sfolderPath)
Set testSubFolders = mainFolderObj.SubFolders
sPath = "C:\&formatDate&\"

For each folderobj in testSubFolders

chkfolderobj = folderObj.Path & "\Action0"

if ( fsObj.FolderExists(chkfolderobj)) then 'The Folder is a QTP test folder'
qtpApp.Open folderObj.Path, True, False
 sResultFolderPath = sPath&folderObj.Name & "\Res" 'Set the results location'
 qtpResObj.ResultsLocation = sfolderPath

 qtpApp.Test.Run qtpResObj , True
 strResult = qtpApp.Test.LastRunResults.Status
 WScript.echo strResult
 qtpApp.Test.Close
 End if
 Next
 'Send Mail
 qtpApp.Quit
 'Release the file System objects 
 Set testSubFolders = Nothing
 Set mainFolderObj = Nothing
 Set fsObj = Nothing 
 Set qtpResObj= Nothing 

 Function formatDate ()
 str= now ()
    str=replace(str,"/","")
    str=replace(str,":","")
    str=replace(str," ","")
    formatDate = mid (str,1,len(str-2))
End Function

Now I am trying to execute these batch file remotely through a Job that launch it. I am facing two issue :

1st : I am having a Interactive Services Detection prompt with a pop up box where I should click on view the message in order to switch to another screen, this is an issue for me as I want UFT to be launched automatically without any user interaction.

2nd Issue : Using this script UFT is not starting even when I click on view message in the service interaction pop up.
I have searched in the internet and I have found a suggestion to open UFT first so I have added this snippet on the top of the script above :

dim commandLine, WshShell

' Define command line 
commandLine = """C:\Program Files (x86)\HP\Unified Functional Testing\bin\UFT.exe"""
Set WshShell = CreateObject("WScript.Shell")

' Start QTP via command line
WshShell.Run commandLine, 8, true

' Wait a while until QTP is loaded (here 10 secs)
WScript.Sleep 10000
set WshShell=nothing  

With this script UFT is launched after I click on the Interactive Services Detection message but the testes are not starting.

So to resume my question is how can I avoid the Interactive Services Detection and launch UFT directly and how I can get tests starting once UFT is launched.

Thanks Zied


Solution

  • Thanks TheBlastOne for your comment, indeed I looked at the docs and it turned out to be a DCOM config issue, I have changed the user type to interactive which has solved the problem.

    Thanks Zied