TryFindSingle case insensitive

Ask general questions here.
anzacthecat
Posts: 31
Joined: Mon Jan 10, 2011 1:05 pm

TryFindSingle case insensitive

Post by anzacthecat » Mon Apr 30, 2012 3:00 pm

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?

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: TryFindSingle case insensitive

Post by sdaly » Mon Apr 30, 2012 3:07 pm

Does the username contain @ ?

anzacthecat
Posts: 31
Joined: Mon Jan 10, 2011 1:05 pm

Re: TryFindSingle case insensitive

Post by anzacthecat » Tue May 01, 2012 3:03 am

No, it may contain \\, but I don't think that can be the problem because it works in Spy.

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: TryFindSingle case insensitive

Post by sdaly » Tue May 01, 2012 8:26 am

Sounds like it could be an escaping issue - you could try this to be sure -

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

anzacthecat
Posts: 31
Joined: Mon Jan 10, 2011 1:05 pm

Re: TryFindSingle case insensitive

Post by anzacthecat » Tue May 01, 2012 10:28 am

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!

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

Re: TryFindSingle case insensitive

Post by Support Team » Tue May 01, 2012 11:41 am

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