Come let us explore together…

Posts tagged ‘extract data from test logs’

Walking through TestComplete logs – Part 3


Hi All,

Let us continue with our “Log” series…

Using logs we can summarize the execution results and send it through mail (As said in previous post) to others and keep them informed the execution results.

I believed few security issues exists in SendMail() function for which I have started a separate thread in Automatedqa Forums.
http://www.automatedqa.com/forums/forum/post/?mode=singlethread&thread=78ec233d-3268-45e1-b7d5-be2803d8cabb

In this post we can dig little deeper in to the log file, where the log information is actually stored. Also we will try to extract the information interested to us.


When you navigate to the log folder, you will find a TestComplete file called “Description.tcLog” from which we can extract a good amount of information


From the above file we can extract information such as ,
1. Who and where the script was executed (Username and System name)
2. Total warning and error count
3. Start and End time of the script

The “Description.tcLog” is an XML file and can get the above values using the script below,

</code>
function GetLogDescription()
{
var tempFolder, xDoc, strTmpValue;
tempFolder = "E:\\Report_TestLog\\";
xDoc = new ActiveXObject("MSXML2.DOMDocument");
xDoc.load(tempFolder + "Description.tcLog");
//User Name
strTmpValue = xDoc.selectSingleNode('Nodes/Node[@name="root"]/Prp[@name="user name"]/@value').text;
Log.Message("User Name: " + strTmpValue);

//Computer Name
strTmpValue = xDoc.selectSingleNode('Nodes/Node[@name="root"]/Prp[@name="computer name"]/@value').text;
Log.Message("Computer Name : " + strTmpValue);
//Warning count
strTmpValue = xDoc.selectSingleNode('Nodes/Node[@name="root"]/Prp[@name="warning count"]/@value').text;
Log.Message("Warning Count : " + strTmpValue);
//Error count
strTmpValue = xDoc.selectSingleNode('Nodes/Node[@name="root"]/Prp[@name="error count"]/@value').text;
Log.Message("Error Count : " + strTmpValue);

xDoc = undefined;
}
<code>

Mostly the management group will be interested in knowing about the overall information about the Automation success rather than individual test cases results.


For such people showing the whole log file may not be the correct way to report, instead we can just summarize the results and show them the numbers – Pass/Fail count.(The above script can solve the purpose)


The TestComplete “Log” object also has few properties which are useful for above purpose. They are,


Log.ErrCount – Reports total number of error in the result
Log.WrnCount – Reports total number of error in the result

We can create folders inside the logs and group similar TestCase/Scenario using Log.CreateFolder function
We can extract log details by each folders which will narrow our reporting,


Log.FolderCount – Reports total number of folders in the log
Log.FolderErrCount – Reports total number of errors in the specified folder
Log.FolderWrnCount – Reports total number of warning in the specified folder

Similarly we have an object under Log object called “CallStackSettings”


Using this object we can Enable (More information about function calls) and Disable (Reduces the log size) call stack settings for TestComplete logs.


Also we can enable/disable the call stack option more accurately to report errors(Log.CallStackSettings.EnableStackOnError), warnings(Log.CallStackSettings.EnableStackOnWarning) etc.,

And as I said early, we can lock(Log.LockEvents) and Unlock(Log.UnlockEvents) any event entering in to the logs.

Hope there is 101 ways to Automate…

Thanks and Regards,
Giri Prasad