|
- '如下三个路径中只能保留需要加载的资源,文件格式必须正确,因为函数会加载该目录下所有文件
- Dim frameRoot:frameRoot = "\\XXXXX\share\TestData\XXXX\XXXX子系统"
- '如下两组参数中元素个数必须相等,否则无法执行
- Dim whatToRep:whatToRep = "------------------------------------>,Reporter.ReportEvent 2,End Step,Expected Results,Description,Begin Step,Start recording here..."
- Dim repToWhat:repToWhat = "**********************************************************************************,Report micPass,结束步骤,预期结果,操作描述,开始步骤,脚本操作内容请如下:"
- Dim whatToRepArr:whatToRepArr = Split(whatToRep,",")
- Dim repToWhatArr:repToWhatArr = Split(repToWhat,",")
- Set fobjShell = CreateObject("Scripting.Filesystemobject")
- Set QTPApplication = CreateObject("QuickTest.Application")
- QTPApplication.Launch
- QTPApplication.Visible = True
- '脚本运行设置
- QTPApplication.Test.Settings.Run.IterationMode = "rngAll"
- QTPApplication.Test.Settings.Run.ObjectSyncTimeOut = 30000
- QTPApplication.Test.Settings.Run.DisableSmartIdentification = True
- QTPApplication.Test.Settings.Run.OnError = "Stop"
- '参数表设置
- QTPApplication.Test.Settings.Resources.DataTablePath = "<Default>"
- '函数文件移除重新加载
- Set AllFiles = fobjShell.GetFolder(frameRoot & "\Functions Library").Files
- QTPApplication.Test.Settings.Resources.Libraries.RemoveAll
- For Each sFile in AllFiles
- QTPApplication.Test.Settings.Resources.Libraries.Add(sFile.Path)
- Next
- Set AllFiles = Nothing
- '场景恢复移除重新加载
- Set AllFiles = fobjShell.GetFolder(frameRoot & "\Recovery Senario").Files
- QTPApplication.Test.Settings.Recovery.RemoveAll
- For Each sFile in AllFiles
- QTPApplication.Test.Settings.Recovery.Add(sFile.Path)
- Next
- Set AllFiles = Nothing
- '配置文件加载
- Set AllFiles = fobjShell.GetFolder(frameRoot & "\Environment").Files
- For Each sFile in AllFiles
- QTPApplication.Test.Environment.LoadFromFile(sFile.Path)
- Next
- Set AllFiles = Nothing
- '替换QC生成的指定注释内容和格式
- For ainx = 1 to QTPApplication.Test.Actions.Count
- vbsContent = QTPApplication.Test.Actions.Item(ainx).GetScript
- For arr = 0 to UBound(whatToRepArr)
- vbsContent = Replace(vbsContent, whatToRepArr(arr), repToWhatArr(arr))
- Next
- vbsContent = Replace(vbsContent, "Quality Center", "Quality Center" & Chr(10))
- QTPApplication.Test.Actions.Item(ainx).SetScript(vbsContent)
- Next
- '保存测试脚本
- QTPApplication.Test.Save
复制代码 |
|