Page 1 of 1

String comparison on micro grams(μg) is failing

Posted: Wed Feb 07, 2018 11:59 pm
by RekhaG
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:
if(string.Compare(volumeText.TextValue,inputVolumeParameter,true)==0)
{
Report.Log(ReportLevel.Info,"MATCH FOUND " );
}

else
{
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?

Thanks,
Rekha

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

Posted: Thu Feb 08, 2018 8:58 am
by odklizec
Hi,

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.