我创建了一组UFT 12(以前是QTP)测试,并创建了一个批处理文件来运行这些测试。
当我在本地运行批处理文件时,测试正常运行。
以下是我使用的脚本:
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
现在我正在尝试通过启动批处理文件的作业来远程执行它们。 我遇到了两个问题:
1. 我面临一个交互式服务检测提示,弹出一个框,我应该点击查看消息以切换到另一个屏幕,在没有用户交互的情况下自动启动UFT是我的问题。 2. 使用此脚本,即使我单击服务交互弹出窗口中的查看消息,UFT也不会启动。 我在互联网上搜索并找到了一个建议先打开UFT的建议,所以我已经在脚本顶部添加了这个代码片段:
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
当我点击交互式服务检测消息后,使用此脚本启动UFT,但测试不会开始。
所以,我的问题是如何避免交互式服务检测并直接启动UFT,以及如何在启动UFT后启动测试。
谢谢 Zied