Forum Discussion

leeasdf9's avatar
leeasdf9
Frequent Contributor
13 years ago

Receive Test Report via Email automatically after Test run possible?

Greetings,

It would be very helpful if I can receive the testLog Report via email automatically after test execution. so that I am able to check the test result in case if I am not in the office by automation workstation. I really appreciate if somebody can provide me the possibility to do it. Jscript sources to do this task are very appreciated. Thanks a lot.

Lee

5 Replies

  • I do not know how anyone else does it but I just have a separate batch file that runs after the test that uses blat to send an email with a  link the the exported mht file.
  • This vbscript version is currently working for me...



    Sub EmailLogResults()

        Dim  tempFolder, xDoc, wrnC, errC

        tempFolder = "C:\temp\tclog1\"

        ' Remove the old folder   

        Call aqFileSystem.DeleteFolder(tempFolder, True)

        ' Prepare a temporary folder

        aqFileSystem.CreateFolder(tempFolder)

        ' Save results to an .xml file

        Call Log.SaveResultsAs(tempFolder, IsXML, True)

        ' Create an XMLDocument

        ' Set xDoc = Sys.OleObject("MSXML2.DOMDocument.4.0")

        Set xDoc = Sys.OleObject("MSXML2.DOMDocument.3.0")

        ' Load the file

        Call xDoc.load(tempFolder & "Description.tcLog")

        ' Check the load result

        If xDoc.parseError.errorCode <> 0 Then 

          Log.Message "File load result: "& xDoc.parseError.errorCode, _

                      "Error code: "      & xDoc.parseError.errorCode & Chr(13) & Chr(10) & _ 

                      "Description: "     & xDoc.parseError.reason & Chr(13) & Chr(10) & _

                      "Line No: "         & xDoc.parseError.line & Chr(13) & Chr(10) & _

                      "Column: "          & xDoc.parseError.linepos & Chr(13) & Chr(10) & _

                      "Source text: "     & xDoc.parseError.srcText

          Exit Sub          

        End If                           

        ' Count warnings

        wrnC = xDoc.selectSingleNode("Nodes/Node[@name='root']/Prp[@name='warning count']/@value").text

        ' Count errors

        errC = xDoc.selectSingleNode("Nodes/Node[@name='root']/Prp[@name='error count']/@value").text

        ' Save results to an .mht file

        Call Log.SaveResultsAs(tempFolder & "TestLogRun1.mht",2)

         ' Send email

        If SendMail(me@domain.com, "smtp.domain.local", "Overnight Test Run 1", "from@domain.com", "Errors = " & errC & "   Warnings = " & wrnC, "Link to log:   \\mycomputer\temp\tclog1\TestLogRun1.mht") Then

          Log.Message "email was sent"

        Else

          Log.Warning "email was not sent"

        End If

    End Sub
  • leeasdf9's avatar
    leeasdf9
    Frequent Contributor
    Thanks Tanya and Jeff for your advices. I think “SaveResultsAs” and “SendingEmail” functions are exact what I want, I will try it out. Thanks a lot.
  • It will helpful for me to generate Email with test report after Test Run completion using Keyword Test instead of script. Thanks in advance