Page 1 of 1

Object Identification using Screen position

Posted: Tue Dec 06, 2011 4:48 pm
by jayam_jp22
Hi Ranorex support team,

I have an application to be automated in which the objects do not have an UNique ID and is been identified with the numeric value in the object. The numeric value is supposed to be changing and so the object identification fails.

Can i use object identification based on position in screen and if so, can you provide me the syntax for using location or screen position in RXPath syntax?

Or is there any other method that i can use for identifying these objects?

Thanks for your effort.

Regards,
Jayaprakash R

Re: Object Identification using Screen position

Posted: Tue Dec 06, 2011 6:11 pm
by Ciege
Just a thought... Do the values have labels next to them? Like does the "50.0" have the label Gain next to it?
If so, and you're willing to write a bit of code, you can have Ranorex search for the label text. Get its relative location, then search for a text element that is just to the right or left (depending on your AUT) of that label text.

Re: Object Identification using Screen position

Posted: Tue Dec 06, 2011 7:29 pm
by Support Team
As Ciege said, if the element holding the value "50.0" is always preceded by a label element "Gain", then you can easily construct a RanoreXPath identifying the value by its label, e.g.:

Code: Select all

.../element/form[@name='Module1']/element/text[@name='Gain']/following-sibling::text
The "following-sibling::" axis tells Ranorex to search for a sibling following the "Gain" element which is also of role "text". For more information on RanoreXPath see the corresponding User Guide or watch or screen casts:
http://www.ranorex.com/support/screencasts.html
http://www.ranorex.com/support/user-gui ... xpath.html

Regards,
Alex
Ranorex Team

Re: Object Identification using Screen position

Posted: Tue Dec 06, 2011 7:31 pm
by Ciege
Support Team wrote:following-sibling::text
Oooh! Thats a good one! :D

Re: Object Identification using Screen position

Posted: Wed Dec 07, 2011 7:31 am
by jayam_jp22
Hi Ciege, Hi Support team,

Thanks for your valuable inputs. That really helped me in identifying the objects.

using the following-sibling in Xpath, now Ranorex identifies all the objects under the Gain label (even the values for the other labels). I wanted to know is there any way that i can use the index of objects to identify the required object. For me i require only the 1st object of all the objects identified.

Please let me know your thoughts.

Regards,
Jayaprakash R

Re: Object Identification using Screen position

Posted: Wed Dec 07, 2011 2:26 pm
by Support Team
Hi,

if the index doesn't change within different executions of your AUT, you should not run into any issue with using the index operator in RanoreXPath to get only the 1st element:

Code: Select all

.../element/text[@name='Gain']/following-sibling::cell[@valid='true'][1]
Regards,
Tobias
Ranorex Support Team

Re: Object Identification using Screen position

Posted: Sat Dec 10, 2011 5:33 am
by jayam_jp22
Hi Support TEam,

Thanks for your inputs. I tried the method you have suggested me and it is not identifying the 1st element alone with indexing done.

So i tried to pull the values out to IList and i'm verifying it for the 1st array only.

For now that solves my problem. Is this a recommended way to read the text value in the object?

Thanks.

Regards,
Jayaprakash R

Re: Object Identification using Screen position

Posted: Mon Dec 12, 2011 10:38 am
by Support Team
Hi,

please try the following path

Code: Select all

.../element/text[@name='Gain']/following-sibling::cell[true=true][1]
Best Regards,
Martin
Ranorex Support Team