Programmatically accessing Ranorex report elements
Posted: Thu Jul 07, 2016 3:05 pm
Hi all, I'm currently working on a project integrating TestRail into our Ranorex automation, and it's been going well so far, but I've run into something that google has been unable to supply an answer to, thus far.
At the end of each test case, I have a module that grabs the status of the test, and then submits that status to TestRail, so the results update in realtime as the tests progress. I'm able to supply the status of the case, and get that sent to TestRail, but the detail information that ends up in the TestRail report is sparse at best. I'd like to make use of the details in the Ranorex report, but so far I'm not able to get more than just the "Description" field for each module that sits within the test case (but not those within the "Setup" and "Teardown" portions).
I was able to find a forum post http://www.ranorex.com/forum/test-suite ... t2064.html that got me partway there. The code I'm using to grab this information is listed below
What I'm trying to get is the detailed report for each module, or more accurately, the text of that detailed report. I'm not concerned with screenshots, and I already have the means to pull any error messages... but those error messages aren't helpful without context. The context can be established within the saved Ranorex report file, but I have to wait until all tests complete to have access to that data, so that eliminates the "realtime reporting" aspect of the project, which is sort of the point to begin with. The information has to be there, because it's being collected throughout the test process. I'm hoping that someone out there has done something similar, and can advise as to where I can pull the text I'm looking for.
At the end of each test case, I have a module that grabs the status of the test, and then submits that status to TestRail, so the results update in realtime as the tests progress. I'm able to supply the status of the case, and get that sent to TestRail, but the detail information that ends up in the TestRail report is sparse at best. I'd like to make use of the details in the Ranorex report, but so far I'm not able to get more than just the "Description" field for each module that sits within the test case (but not those within the "Setup" and "Teardown" portions).
I was able to find a forum post http://www.ranorex.com/forum/test-suite ... t2064.html that got me partway there. The code I'm using to grab this information is listed below
Code: Select all
foreach (IReportItem rep in TestReport.CurrentTestCaseActivity.Children)
{
if(rep.ToString() == "Ranorex.Core.Reporting.TestModuleActivity")
{
string DetailMessage = (rep as TestModuleActivity).DetailMessage;
string ErrorMessage = (rep as TestModuleActivity).ErrorMessage;
string Status = (rep as TestModuleActivity).Status.ToString();
TestCaseReport += "\r\n\r\n" + DetailMessage + " - " + Status;
if(Status.ToLower() != "success")
{
TestCaseReport += " - " + ErrorMessage;
}
}
}