Page 1 of 1

ranorex spy unique id setting

Posted: Tue Aug 14, 2012 2:34 pm
by martinsw
Hi,

Since Ranorex 3.3 was released, Ranorex spy can now search for elements based on their unique id (when the spy setting is enabled).

E.g. .//span[#'PageLayout_lblSelectUserTitle']

Please can you advise, how should I write the Ranorex path for the element above if I want to add additional attributes for this element, such as validating its innertext value. The following is not valid syntax:

.//span[#'PageLayout_lblSelectUserTitle' and @innertext~'Fred']

so I have been using the following approach

.//span[#'PageLayout_lblSelectUserTitle']/../span @innertext~'Fred']

Is this the best/most efficient way to do it?

Thanks

Re: ranorex spy unique id setting

Posted: Thu Aug 16, 2012 9:20 am
by Support Team
Hello,

The unique id for an HTML element should be unique within the HTML document. That's why the path .//span[#'PageLayout_lblSelectUserTitle' and @innertext~'Fred'] would make no sense and is not supported by the RxPath. If your id's are not unique you should not use the unique id search because you would get problems with finding elements and executing your tests.
What is the reason for doing that?

Regards,
Bernhard
Ranorex Support Team

Re: ranorex spy unique id setting

Posted: Thu Aug 16, 2012 1:04 pm
by martinsw
Hi Bernard,

IMaybe I'm not fully understanding what the search by unique id feature is actually doing.

Let me give you an example of what I am trying to achieve and then maybe any misunderstandings that I have will become clearer to you and you can put me right.

Attached is a snapshot of a label within my application. The innertext attribute of this label is "Business Partner" and the id attribute has a value of 'PageLayout_lblBusinessPartner'. The attached screenshot shows the appearance of this label within my application.

When I search for the element in spy, with the unique id attribute switched on, the returned path is "//span[#'PageLayout_lblBusinessPartner']".

I want to search by unique id as it keeps my xpaths shorter and speeds up my tests. However, I also want to validate the elements existence based on the fact that its id attribute matches the unique id and its innertext attribute has a value of "Business Partner". Please can you tell me how I should write an xpath that does this?

If I am not asking a valid question please can you explain why it is not valid?

Thanks.

Re: ranorex spy unique id setting

Posted: Fri Aug 17, 2012 9:18 am
by Support Team
Hello,

Thank you for describing your issue.
The use of relations in the RxPath when you use the uniqueId search is not directly supported in Ranorex to use, but there are two workarounds to handle this.

//span[@id='PageLayout_lblBusinessPartner' and @innertext='Business Partner:']
It should not be much slower than the uniqueId search.

The following path describes a AND relation between the uniqueid and the innertext attribute.
//span[#'PageLayout_lblBusinessPartner'][@innertext='Business Partner:']

Regards,
Bernhard
Ranorex Support Team

Re: ranorex spy unique id setting

Posted: Fri Aug 17, 2012 11:53 am
by martinsw
Thanks Bernhard!