Different rxpaths for same control in different machine

Ask general questions here.
vengaishiva
Posts: 62
Joined: Wed Mar 09, 2011 4:40 pm

Different rxpaths for same control in different machine

Post by vengaishiva » Wed Sep 07, 2011 2:40 pm

Hi,
I am having a button in my system tray. When i click that button, it will show me a context menu. I have to click the menu item named 'X'. When i Click the 'X', it will display a submenu, from there i have to select menu item 'Y'. This is the scenario, i want to automate.

For Item 'X' the rx path is /contextmenu[@processname='Launcher' and @class='#32768' and @instance='0']/contextmenu/menuitem[20]

For Item 'Y' (the sub menu, which appears only after clicking menu item 'X') the rx path is /contextmenu[@processname='Launcher' and @class='#32768' and @instance='1']/contextmenu/menuitem[2]

Now both these paths works fine in my machine. But when i move the same code into different machine, both for Item 'X' and item 'Y' the instance should be zero in the rxpath, then only it works. Why this difference.

Also please note that, I have analyzed both the context menu items, and they have similar properties (only handle is varying, that cannot be used to differentiate them in the code, because it is dynamically generated.)

I cannot provide you the snap shot, because the application is under secure location.

My question here is, even if i go by the second machine's rxpath, (where @instance='0' for both the items 'X' and 'Y') how it is correctly selecting the sub menu item 'Y', because the same rx path for 'Y' can lead to the second menu item in the contextmenu where item 'X' is found. (i.e the same path is applicable for 2 nd item in the context menu where item 'X' resides)

Kindly help,

Regards,
Siva R S

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

Re: Different rxpaths for same control in different machine

Post by Support Team » Wed Sep 07, 2011 3:30 pm

Hi,

Do you have tested if the RxPath is still the same after a restart of your AUT?
Also please note that, I have analyzed both the context menu items, and they have similar properties (only handle is varying, that cannot be used to differentiate them in the code, because it is dynamically generated.)
So it seems that the attributes, at least some of them, of the element are randomly generated. What you should do is deleting such dynamic attributes out of your RxPath. For instance if the "processname" is unique you can delete the other attributes and use the following RxPath:
/contextmenu[@processname='Launcher']/contextmenu/menuitem[20]
Are there any other unique attributes for the last menuitem?
Please take a look at the following blogs, they describes how you can edit the RxPath:
http://www.ranorex.com/blog/ranorexpath-tips-and-tricks
http://www.ranorex.com/blog/eliminate-d ... norexpaths

Regards,
Markus
Ranorex Support Team
.
Image