String comparison on micro grams(μg) is failing

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 17
Joined: Fri Sep 22, 2017 12:47 am

String comparison on micro grams(μg) is failing

Post by RekhaG » Wed Feb 07, 2018 11:59 pm

Hi ,

There is a button on which the text is displayed in micro gram units. For example: 20 μg
Steps i followed:
1. Set the expected value in the parameter using data binding . For example: inputVolumeParameter=20 μg
2.Loop through the list of available buttons through and verify if the text on the button is same as the input parameter that is set in step1
For Example:
Report.Log(ReportLevel.Info,"MATCH FOUND " );

Report.Log(ReportLevel.Info," MATCH NOT FOUND " );

String comparison is always failing on the 'μg' when i did the following

string[] tempStr = volumeText.TextValue.Split(new string[]{" "}, StringSplitOptions.None);
string [] tempStr1= Volume.Split(new string[]{" "}, StringSplitOptions.None);

bool b= string.Compare(tempStr[0], tempStr1[0], CultureInfo.InvariantCulture, CompareOptions.IgnoreSymbols ) == 0;
bool b1= string.Compare(tempStr[1], tempStr1[1], CultureInfo.InvariantCulture, CompareOptions.IgnoreSymbols) == 0;

Report.Log(ReportLevel.Info,tempStr[0] +" " + tempStr1[0] + " " + b);
Report.Log(ReportLevel.Info,tempStr[1] +" " + tempStr1[1] + " " + b1);

Can anyone help me with this?


User avatar
Ranorex Guru
Ranorex Guru
Posts: 3950
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: String comparison on micro grams(μg) is failing

Post by odklizec » Thu Feb 08, 2018 8:58 am


As mentioned many times before, it's next to impossible to suggest something sensible without seeing, at very least, Ranorex snapshot of the problematic element. Could you please upload one? My guess is that there is some kind of leading/trailing non-printable character and so the comparison fails (despite CompareOptions.IgnoreSymbols)? But as mentioned, without snapshot, it's impossible to tell what's wrong.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration