Page 1 of 1

TryFindSingle case insensitive

Posted: Mon Apr 30, 2012 3:00 pm
by anzacthecat
I am trying to use the path below to find a matching username but it is not being found.

string XPath_to_find_user = ".//td[@innertext~'(?i:"+ User_name) +")']";
if(User_table.TryFindSingle<TdTag>(XPath_to_find_user,30000, out Found))
{
Found.Click();
}

If I try the same path in the Spy it works perfectly and quite quickly.

If I take out the case insensitive bit and search for:
string XPath_to_find_user = ".//td[@innertext='" + User_name + "']";

it works perfectly. So there must be some problem with the case insensitive bit?

Re: TryFindSingle case insensitive

Posted: Mon Apr 30, 2012 3:07 pm
by sdaly
Does the username contain @ ?

Re: TryFindSingle case insensitive

Posted: Tue May 01, 2012 3:03 am
by anzacthecat
No, it may contain \\, but I don't think that can be the problem because it works in Spy.

Re: TryFindSingle case insensitive

Posted: Tue May 01, 2012 8:26 am
by sdaly
Sounds like it could be an escaping issue - you could try this to be sure -

user_name = System.Text.RegularExpressions.Regex.Escape(user_name);

Re: TryFindSingle case insensitive

Posted: Tue May 01, 2012 10:28 am
by anzacthecat
Hi,

it's not an escaping issue:

".//td[@innertext='abc\\abc']"

works and

".//td[@innertext~'(?i:abc\\abc)']"

does not work, but does work in Spy

Help!

Re: TryFindSingle case insensitive

Posted: Tue May 01, 2012 11:41 am
by Support Team
Hi,
anzacthecat wrote:".//td[@innertext~'(?i:abc\\abc)']"
Are you sure that this is no escaping issue? Spy does this automatically but if you use a string in code and you use "\\" the compiler only takes one "\" for your string. Did you debug the issue? I would recommend so, because then you will see if the string is the correct one you expect.

Regards,
Peter
Ranorex Team