QTP批量執行并發郵件
Option Explicit '***************************************************************** '腳本說明:公共變量聲明,路徑根據實際環境修改 '***************************************************************** Dim ReportLocation '報告存放路徑 ReportLocation = "D:\project\QTP\qtpscript\" Dim QtpLocation 'Qtp安裝路徑 QtpLocation = "D:\softwaretesting\Mercury Interactive\QuickTest Professional\bin\QTPro.exe" '***************************************************************** '腳本說明:啟動QTP '***************************************************************** Dim WshShell,oExec set WshShell = WScript.CreateObject("WScript.Shell") Set Exec = WshShell.Exec (QtpLocation) Set WshShell = Nothing WScript.Sleep 60000 '等待1分鐘 '***************************************************************** '腳本說明:判斷文件是否存在,存在刪除 '***************************************************************** Dim oFSO ' 創建一個文件系統對象 set FSO = CreateObject ("Scripting.FileSystemObject") CheckFileExists(ReportLocation) Function CheckFileExists (FilePath) FilePath = FilePath &"測試結果1.html" ' 檢查文件是否存在,如果存在刪除 CheckFileExists = oFSO.FileExists(FilePath) 'MsgBox CheckFileExists If (CheckFileExists = true) Then oFSO.DeleteFile (FilePath) End if End Function '***************************************************************** '腳本說明:批量執行腳本并生成摘要報告 '***************************************************************** Dim oMTM ' 創建 Multi Test Manager 對象 Set MTM = CreateObject("MultiTestManager.Application") oMTM.Visible = True ' 修改運行時的默認設置 Dim oRunSettings Set RunSettings = oMTM.Preferences.RunSettings oRunSettings.Iterations = 1 oRunSettings.CloseQuickTest = True '打開注釋啟用定時調度 'oRunSettings.ScheduleRun = True 'oRunSettings.Day = 3 'oRunSettings.Month = 12 'oRunSettings.Year = 2009 'oRunSettings.Second = 00 'oRunSettings.Minute = 55 'oRunSettings.Hour = 15 ' 修改報告的默認設置 Dim oReportSettings Set ReportSettings = oMTM.Preferences.ReportSettings oReportSettings.CreateReport = True oReportSettings.OverwriteReport = False oReportSettings.DefaultLocation = False oReportSettings.ReportLocation = ReportLocation '報告存放路徑 oReportSettings.ReportName = "測試結果" oReportSettings.ViewReport = True '批量執行腳本:腳本的目錄,是否執行,執行結果存放位置 oMTM.AddTestScript. "D:\project\QTP\qtpscript\rarTest", True,ReportLocation 'oMTM.AddTestScript. "D:\project\QTP\qtpscript\rarTest", True,ReportLocation 根據腳本進行添加 ' 運行腳本 oMTM.Run while ( oMTM.IsRunning ) Wend oMTM.Quit Set RunSettings = Nothing Set ReportSettings = Nothing Set MTM = Nothing |
'***************************************************************** '腳本說明:將運行結果發送郵件 '***************************************************************** Dim SendTo, Subject, Body, Attachment 'SendTo ="test@163.com;test1@163.com" '發送多個郵箱以分號分割 SendTo ="test@163.com" Subject ="自動化測試結果" Body ="自動化測試結果" Attachment =ReportLocation&"測試結果1.html" 'SendMail SendTo, Subject, Body, Attachment Function SendMail(SendTo, Subject, Body, Attachment) Dim ol,Mail Set l=CreateObject("Outlook.Application") Set Mail=ol.CreateItem(0) Mail.to=SendTo Mail.Subject=Subject Mail.Body=Body If (Attachment <> "") Then Mail.Attachments.Add(Attachment) End If ' Mail.display '郵件顯示 Mail.Send ol.Quit Set Mail = Nothing Set l = Nothing End Function |
posted on 2014-04-10 10:45 順其自然EVO 閱讀(371) 評論(0) 編輯 收藏 所屬分類: qtp