qileilove

          blog已經轉移至github,大家請訪問 http://qaseven.github.io/

          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

          <2014年4月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 独山县| 珲春市| 建阳市| 广西| 孝感市| 巨野县| 涿鹿县| 光泽县| 永德县| 张家川| 全南县| 永春县| 渝中区| 壤塘县| 沙湾县| 泾源县| 陕西省| 新疆| 林周县| 策勒县| 威远县| 太仓市| 敦煌市| 丰原市| 湄潭县| 汨罗市| 铁岭市| 钦州市| 东海县| 泸州市| 青龙| 渑池县| 宕昌县| 宝清县| 双桥区| 邛崃市| 紫阳县| 泰来县| 铁岭县| 友谊县| 卓资县|