Page 1 of 1

Meaning of RanoreXPath specification

Posted: Tue Jul 16, 2019 6:22 am
by Thet Thet
Hi,
I want to know the meaning of RanoreXPath specification.
Example,
/*
/?
//
@id
@accessiblename
#
.etc.

I want to also know the difference between .//input[#'LOGIN_USERCODE'] and .//input[@id='LOGIN_USERCODE'].
thank you.

Re: Meaning of RanoreXPath specification

Posted: Tue Jul 16, 2019 7:50 am
by Julien Diot
Hi, look at this side, it'll give you some information.

https://www.ranorex.com/help/latest/ran ... -examples/

Re: Meaning of RanoreXPath specification

Posted: Tue Jul 16, 2019 7:50 am
by odklizec
Hi,

Have you checked Ranorex user guide yet? Of course, user guides are for noobs, but you know, sometimes, you can find surprisingly useful info in them ;) Seriously, check the user guide. Anything I, or anyone else, would answer here, would be just a reproduction of information, already available in the user guide...
https://www.ranorex.com/help/latest/ran ... blueprint/
https://www.ranorex.com/help/latest/ran ... escription
https://www.ranorex.com/help/latest/ran ... doperators

Don't forget on samples:
https://www.ranorex.com/help/latest/ran ... -examples/

And check also Ranorex xpath-related webinar...
https://www.ranorex.com/automated-testi ... norexpath/

Re: Meaning of RanoreXPath specification

Posted: Tue Jul 16, 2019 9:06 am
by Thet Thet
Hi,
Thanks you for your reply. I checked Ranorex Userguide. But I can't see anything about #.
So, I don't understand well the difference between .//input[#'LOGIN_USERCODE'] and .//input[@id='LOGIN_USERCODE'].
Thanks you.

Re: Meaning of RanoreXPath specification

Posted: Tue Jul 16, 2019 10:02 am
by odklizec
Hi,

'#' means unique id, while '@id' means standard id attribute. The difference is, that unique id allows faster and more reliable element identification, as long as the id is not dynamic ;) The downside of using unique id in the xpath is, that it does not accept other attributes (like @visible and others), so the xpath must be constructed slightly differently. Typically, if the unique id is used, other attributes should not be required. Here is an examples:

To add visibility attribute to element with unique id, it must be done like this:
.//input[#'LOGIN_USERCODE'][@visible='True']

With standard id attribute, it can be done like this:
.//input[@id='LOGIN_USERCODE' and @visible='True']

Both xpaths are doing the same, but the one with unique id could be slightly faster and mainly, it should work even if you remove all preceeding xpath elements.