Forum Discussion

googleid_109910's avatar
googleid_109910
Occasional Contributor
11 years ago

How to extract messages created by the user from the logs?

Hi All,

I wanted to extract  only the messages sent through 'Log.Message()' instruction from my test log xml file(TestLog.xml). I thought of filtering by the .gif file name associated with that message. The .gif file is associated with the icon signifying that its a 'message type'. But these .gif files have different names in different logs nor there is any definite pattern in naming these files. So i wanted to know if there is any way for me to extract messages sent  through 'Log.Message()' instruction from my test log xml file.



Thank you for the help in advance.
  • Have you considered creating a wrapper function that writes a string to a text file along with writing to the log? That way you don't have to write a tool to extract certain messages. I use something like the (untested) code below to dump a CSV-like file that I import into Excel. My scenario is that I'm testing ~800 products and doing 40k+ validations. Searching through the logs is too time consuming so I export a text file, load it into Excel, and then I can filter down to only the failures, etc. for easier investigation and bug entry. I just attach the resulting Excel sheet with all the failures.





    function LogMessage(msg)

    {

        WriteMessage(msg);

        Log.Message(msg);

    }



    function WriteMessage(msg)

    {

        // simple example to give you an idea of how writing to a text file would work from an automation script

        var filePath = "c:\log.txt";

        // look up documentation on WriteToTextFile() for more details

        aqFile.WriteToTextFile(filePath, msg, aqFile.ctANSI, true);

    }

  • Read the page on the Log.Message Method: http://support.smartbear.com/viewarticle/56293/. There is an optional Picture parameter which is the picture I'm assuming you are referring to? If you look at the Picture Object page there are examples of how to write those pictures to file.



    I'm thinking you might be referring to one of the other Log methods... Log.Error, etc. that writes a picture to the log by default.
  • googleid_109910's avatar
    googleid_109910
    Occasional Contributor
    Thanks for the reply Jeff. I would write into text file, but i also want to extract the picture/screenshot attached to that log message. Thats the reason we are sticking to xml file or is there any alternate way to do that?