zepplin 发表于 2010-12-17 14:10:46

QTP之AOM的一个bug

即使在脚本中写qtApp.Options.Run.ViewResults = True,测试完成也不会自动打开测试结果。查了很多资料,发现这确实是一个bug。一个老外和我的问题一样:
http://www.sqaforums.com/showflat.php?Cat=0&Number=432032&an=0&page=640

从论坛拷贝的一段代码:
On Error Resume Next
error.clear
Dim qtApp
Dim qtTest
Dim qtResultsOpt
Dim fso, MyFile,TestName
Const ForReading = 1, ForWriting = 2

Set WshShell = CreateObject("WScript.Shell")
WshShell.Popup "开始批量执行自动化测试脚本!", 3, "AutoTest", 0 + 64

Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch

qtApp.Visible = True
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = True

Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile(".\RunList.txt", ForReading, True)
Do While MyFile.AtEndOfStream <> True
      TestName = MyFile.ReadLine

      qtApp.Open TestName, True
      Set qtTest = qtApp.Test
      qtTest.Settings.Run.OnError = "Dialog"
      
      Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")
      qtResultsOpt.ResultsLocation = TestName &"\AutoRes"

      qtTest.Run qtResultsOpt, True
      
      MsgBox qtTest.LastRunResults.Status
      
      qtTest.close
Loop

MyFile.Close
qtApp.Quit

'MsgBox "自动化测试脚本执行完毕!脚本测试结果存放在各自的AutoRes目录下,请用QTP result工具查看"

Set fso = Nothing
Set qtResultsOpt = Nothing         
Set qtTest = Nothing      
Set qtApp = Nothing
Set WshShell = Nothing

heng612 发表于 2010-12-20 17:40:34

顶期待版主更多的BUG
页: [1]
查看完整版本: QTP之AOM的一个bug