Page 1 of 1

.RXLOG trims spaces of var values captured by C# User Code

Posted: Wed Feb 19, 2014 11:58 pm
by RanoTester
PROBLEM SUMMARY: When a Ranorex script has executed C# User Code that captures a variable value containing multiple spaces, i.e., such as "Lost In Denver", and then publishes that variable value via a 'Report.Log' command (for potential troubleshooting purposes), the variable value in the resulting .RXLOG file is misrepresented. How is it misrepresented? All spaces in this variable value beyond one space are trimmed thus resulting in the variable displaying in a reduced, shortened way in the .RXLOG file compared to how it actually looked within the Web App at playback time.

EVEN IN THIS BUG REPORT, in above-stated Summary, the additional spaces are being removed so that if 5 spaces are present between "In" and "Denver", the display is still "Lost In Denver".

In this Denver example, the value "Lost In Denver" will appear as "Lost In Denver", i.e., with 4 of the 5 spaces in the variable value (i.e., That contained value "Lost In Denver") being incorrectly trimmed by the .RXLOG file.

DESIRED BEHAVIOR: The .RXLOG file should display the actual variable value without attempting to trim out additional spaces. In this Denver example, .RXLOG should have displayed the value as "Lost In Denver" rather than simply "Lost In Denver".

NOTE: This appears to be an RXLOG file problem only. In the above-stated Denver example, Ranorex correctly stores the actual value, i.e., "Lost In Denver", into the variable and can use that true / accurate variable value at playback time.

BUSINESS IMPACT: This .RXLOG trim problem can cause havoc in troubleshooting certain data-driven Ranorex scripts where we depend on the resulting .RXLOG file to state, via a call of C# User Code, what exact variable values Ranorex found at playback time. The net result is that in certain cases, due to this problem, the .RXLOG file can be displaying a false value / doc number.

Re: .RXLOG trims spaces of var values captured by C# User Code

Posted: Fri Feb 21, 2014 2:54 pm
by Support Team
Hello RanoTester,

The message is a HTML representation of the committed value.
With only a few exceptions, HTML treats whitespace characters (spaces, tabs, and newlines) differently from ordinary characters. In general, a single whitespace character--including newlines--or a sequence of whitespace characters are treated as a single space and leading/trailing whitespace is eliminated. This is known as 'collapsing whitespace'.- http://www-sul.stanford.edu/tools/tutor ... space.html
Therefore you need to convert the “spaces” within your attribute value to protected “spaces”.
var aBTxt = repo.Anything.ABTxt.Element.GetAttributeValue("Text");
        
        	
        	//convert string to html with protected spaces
        	StringBuilder sb = new StringBuilder();
        	sb.Append("<p>");
        	sb.Append(aBTxt.ToString());
        	//convert spaces
        	sb.Replace(" ", "&#160;");
        	sb.AppendLine("</p>");
        	string html = sb.ToString();

Report.LogHtml(ReportLevel.Info, "Anything", html);
Regards,
Robert

Re: .RXLOG trims spaces of var values captured by C# User Code

Posted: Fri Feb 21, 2014 3:03 pm
by krstcs
Why does Ranorex not do this translation automatically when converting variables? That seems like the better way to handle this.

Ranorex should represent values as they are in test when outputting to the report file, that means that Ranorex should automatically "escape" characters that HTML will "fix".


This is still a problem with Ranorex from my view, since you guys knew about the HTML translation issue, you should already have taken it into account when creating the report. We should not have to custom code things so that they get printed to the report correctly.

Re: .RXLOG trims spaces of var values captured by C# User Code

Posted: Mon Feb 24, 2014 3:13 pm
by Support Team
Hi krstcs,

I have added a feature request to our internal bug-tracking system in order to discuss a future implementation. Thank you!

Regards,
Robert