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?
TryFindSingle case insensitive
Re: TryFindSingle case insensitive
Does the username contain @ ?
-
- Posts: 31
- Joined: Mon Jan 10, 2011 1:05 pm
Re: TryFindSingle case insensitive
No, it may contain \\, but I don't think that can be the problem because it works in Spy.
Re: TryFindSingle case insensitive
Sounds like it could be an escaping issue - you could try this to be sure -
user_name = System.Text.RegularExpressions.Regex.Escape(user_name);
user_name = System.Text.RegularExpressions.Regex.Escape(user_name);
-
- Posts: 31
- Joined: Mon Jan 10, 2011 1:05 pm
Re: TryFindSingle case insensitive
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!
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!
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: TryFindSingle case insensitive
Hi,
Regards,
Peter
Ranorex Team
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.anzacthecat wrote:".//td[@innertext~'(?i:abc\\abc)']"
Regards,
Peter
Ranorex Team