Forum Discussion

ankita_sharma's avatar
ankita_sharma
Occasional Contributor
11 years ago

Reading the logitems generated from Log.SaveResultsAs Method in VBscripting

Hi All,



I am trying to read the logitems which is generated from the Log.SaveResultsAs Method.



My intention is to get the Pass, Failed, and Error Items from the logfile.



I found this piece of code from the Smartbear utility scripts:



But i am not able to run this code. Please help me on it



I get error on the following line:





tempFolder = aqEnvironment.GetEnvironmentVariable("temp") & "\" &_




GetTickCount() & "\"










Sub Test()




Call Log.Message("Current log items are in the Additional Information panel", GetLogItems())




End Sub




 




Function GetLogItems()




Dim tempFolder, xDoc, result








tempFolder = aqEnvironment.GetEnvironmentVariable("temp") & "\" &_




GetTickCount() & "\"








If 0 <> aqFileSystem.CreateFolder(tempFolder) Then




Log.Error("The " & tempFolder & " temp folder was not created")




GetLogItems = ""




Exit Function




End If




If Not Log.SaveResultsAs(tempFolder, lsHTML) Then




Log.Error("Log was not exported to the " & tempFolder & " temp folder")




GetLogItems = ""




Exit Function




End If








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




xDoc.load(tempFolder & "root.xml")




result = LogDataToText(xDoc.childNodes.item(1), 0, " ")








Call aqFileSystem.DeleteFolder(tempFolder, True)




GetLogItems = result




End Function




 




Function LogDataToText(logData, indentIndex, indentSymbol)




Dim i, result








If "LogData" <> logData.nodeName Then




LogDataToText = ""




Exit Function




End If




 




result = ""




For i = 0 To indentIndex - 1




result = result & indentSymbol




Next




result = result & "Name: " & logData.getAttribute("name") & ", status: " &_




GetTextOfStatus(logData.getAttribute("status")) & vbCrLf








For i = 0 To logData.childNodes.length - 1




result = result & LogDataToText(logData.childNodes.item(i),_




indentIndex + 1, indentSymbol)




Next




LogDataToText = result




End Function




 




Function GetTextOfStatus(statusIndex)




Select Case statusIndex




Case "0" GetTextOfStatus = "OK"




Case "1" GetTextOfStatus = "WARNING"




Case "2" GetTextOfStatus = "FAILED"




Case Else GetTextOfStatus = "UNDEFINED"




End Select




End Function




Thank You.

2 Replies

  • VLapidus's avatar
    VLapidus
    Frequent Contributor
    This code is meant to be used for the log of a current execution
  • Hi,



    Maybe you need to add the prefix "Win32API" like below:


    Win32API.GetTickCount()



    I have  other question with same goal, Is there a way to get status (Passed, Failed, Warning...) from test results that run remotelly using Network Suite configuration?



    Any Help would be appreciated.



    Regards,

    Sofia.