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

Bug reports.
RanoTester
Posts: 18
Joined: Mon Jan 14, 2013 7:16 pm

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

Post by RanoTester » Wed Feb 19, 2014 11:58 pm

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.
Attachments
Figure 2 - C# User Code.JPG
C# User Code - This is what publishes the variable value found at playback
Figure 2 - C# User Code.JPG (26.01 KiB) Viewed 1230 times
Figure 3 - RXLOG File - Problem - Spaces Trimmed.JPG
Problem: RXLOG file - Notice how the value appears simply as "Lost In Denver" when the variable value was actually contained 5 spaces after "Lost In" at playback time
Figure 3 - RXLOG File - Problem - Spaces Trimmed.JPG (22.84 KiB) Viewed 1230 times
Figure 1 - Spy - Actual Text Value.JPG
Ranorex Spy - Displaying the Actual Value
Figure 1 - Spy - Actual Text Value.JPG (54.54 KiB) Viewed 1230 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

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

Post by Support Team » Fri Feb 21, 2014 2:54 pm

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
.
Image

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

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

Post by krstcs » Fri Feb 21, 2014 3:03 pm

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.
Shortcuts usually aren't...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

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

Post by Support Team » Mon Feb 24, 2014 3:13 pm

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
.
Image