Extracting fields from .rxlog.data file

Class library usage, coding and language questions.
JimLin
Posts: 38
Joined: Mon Jun 02, 2014 4:23 pm

Extracting fields from .rxlog.data file

Post by JimLin » Wed Jan 10, 2018 7:02 pm

Hi,

There might be an easier way to achieve this, I have a requirement to not only send an email with the report file attached at the end test run, but for the email body itself to contain a high level view of what happened in the test run, i.e

Test execution time
Test run duration
Number of passes/fails
Test 1 = passed
Test 1 duration
Test 2 = failed
Test 2 duration
Test 2 failure reason
Test 2 failure error
etc

I have tried to parse the .rxlog.data file, as that seems to contain the information that I require, but it seems (to me) to be in an unusual xml format, which makes it difficult to get to the data elements I need.

Code: Select all

<activity
	result="Failed"
	duration="218ms"
	durationms="218"
	type="test-module"
	rid="38a89e52f2a49ba"
	totalerrorcount="1"
	totalwarningcount="0"
	totalsuccesstestcasecount="0"
	totalfailedtestcasecount="0"
	totalblockedtestcasecount="0"
	childsuccesscount="0"
	childfailedcount="0"
	childblockedcount="0"
	totalsuccesscount="0"
	totalfailedcount="0"
	totalblockedcount="0"
	modulename="test_fileDrop"
	displayName="test_fileDrop"
	moduleid="7cd3d3e8-4e4c-4263-96e3-587cf1143308"
	moduletype="UserCode"
	iteration="1"
	activity-exectype="execute"
	testentry-activity-type="testmodule">
	<errormessage>
		Validation failed.
	</errormessage>
	<varbindings>
	</varbindings>
	<item
		timeRelativeToTestSuiteStartTime="00:01.788"
		timeRelativeToTestModuleStartTime="00:00.078"
		timeWallClock="14:51:34"
		time="00:01.788"
		level="Failure"
		category="Validation"
		errimg="images_AnotherCompany_f98148c5\AnotherCompany_f98148c5_d866d5d9_trace.jpg"
		errthumb="images_AnotherCompany_f98148c5\AnotherCompany_f98148c5_d866d5d9_trace_thumb.jpg">
		<message>
		Validation failed.
		</message>
		<metainfo
			codefile="c:\Users\Fred.Brown\source\Workspaces\Test\AnotherCompany_Automation_POC\AnotherCompany_Automation_POC\Modules\fileHelper.cs"
			codeline="49"
			loglvl="Failure">
		</metainfo>
	</item>
</activity>
For example, an 'activity' node has an opening '<activity' tag which contains all of the inner text before it gets to '>'. before the closing </activity> tag, there are other nested 'activiy' nodes. The closing </activity> tag doesn't come until much later in the data file. I have been banging my around this all day.

The code below will get to each of the 'activity' nodes and display the furthest one it gets to, but whist the code will loop and get all of the inner text and display it in the report, but I have been unable to extract a single item, i.e. 'modulename="test_fileDrop"'.

Code: Select all

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("C:\\RanorexTestRunReports\\AnotherCompany_Automation_20180110_145132.rxlog.data");
XmlNode reportInfo = xmlDoc.SelectSingleNode("//report/activity/activity/activity/activity/activity");
		
foreach (XmlAttribute attr in reportInfo.Attributes)  
{  
  Report.Info(attr.InnerText);  
}
I will then obviously need to cycle through the rest of the data in the file to pull out all the other test case results.

I have also attached the .rxlog.data file I was using for my testing.

Any suggestions that people can supply to help me solve this would be greatly appreciated.

Cheers,
JimLin

JimLin
Posts: 38
Joined: Mon Jun 02, 2014 4:23 pm

Re: Extracting fields from .rxlog.data file

Post by JimLin » Thu Jan 11, 2018 5:14 pm

I've just realised, I should have said that I am on Ranorex version 7.2 on a Windows 10 VM.