Launching UFT ( QTP ) Tests remotely through a bat

2019-03-30 08:28发布

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

2条回答
Animai°情兽
2楼-- · 2019-03-30 08:48

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

查看更多
Rolldiameter
3楼-- · 2019-03-30 08:49

Here is how you change the user in the DCOM config to interactive.

  1. On the computer where you want to run the automation script, choose Start > Run. The Run dialog box opens.
  2. Enter dcomcnfg and click OK. The Distributed COM Configuration Properties dialog box or the Component Services window opens (depending on your operating system) and displays the list of COM applications available on the computer.
  3. Select QuickTest Professional Automation from the list and open the Properties dialog box for the application. (Click the Properties button or right-click and chooseProperties, depending on your operating system.)

  4. In the QuickTest Professional Automation Properties dialog box, click the Identity tab and select the interactive user option.

查看更多
登录 后发表回答