Menu path change different software version

Ranorex Spy, Recorder, and Studio.
dariof
Posts: 12
Joined: Tue Oct 15, 2013 1:50 pm

Menu path change different software version

Post by dariof » Wed Nov 13, 2013 10:07 am

I have different versions of a software with a different menu.
Is it possible to make sure that I read the AutomationId directly without going through the path of the menu?
In fact, the menu changes:
in the first version is /treeitem[3]/treeitem[4]/element[@automationid='26226']
but in the other is /treeitem [3]/treeitem [2]/element[@automationid='26226']

I'd like to click to element[@automationid='26226'] but I do not want to change the code.

Thank you

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Menu path change different software version

Post by krstcs » Wed Nov 13, 2013 2:39 pm

Try this:

"treeitem[3]/?/?/element[@automationid='26226']"

This will find the element as long as it's parent, grandparent or great-grandparent is a treeitem.

The ? means that that location in the XPath is optional.
Shortcuts usually aren't...

Alena
Posts: 20
Joined: Fri Feb 22, 2013 7:50 pm

Re: Menu path change different software version

Post by Alena » Wed Nov 13, 2013 10:43 pm

Hi dariof,
If you're sure that middle treeitem element always exists but only index changes and no other nodes may be placed between the existing ones in different versions, I'd offer to leave it in as
/treeitem[3]/treeitem/element[@automationid='26226']
In this case the difference may be several milliseconds but in large test suites this really saves time and leads to improving your coding skills because it's more precise.
From my previous Rx experience, the more detailed path you provide, the faster Rx will find the element for this path. Just don't forget to make sure about how much dynamic the nodes are and if they should be "/node[index]/" or "/node/" or "/?/".

dariof
Posts: 12
Joined: Tue Oct 15, 2013 1:50 pm

Re: Menu path change different software version

Post by dariof » Thu Nov 14, 2013 11:35 am

Thanks for the reply.
Last question, Can I set the default recording without indexes?
I' d like to have path without indexes.

Now the default recording is this:
/treeitem[3]/treeitem[4]/element[@automationid='26226']

I'd like to have default recording like this:
/treeitem/treeitem/element[@automationid='26226']

Is it possible? Thanks!

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

Re: Menu path change different software version

Post by Support Team » Thu Nov 14, 2013 5:20 pm

Hello dariof,

If I got your question correctly, you don't want to have indices in your path.
In general, the 'Text', 'AccessibleName' or 'AccessibleRole' attribute is used to uniquely identify a TreeItem.

Do you have such attributes for your TreeItem in your application that uniquely identifies it?
Could you please post a Ranorex Snapshot of your application?
Please take a look at our User Guide for more information on how to create snapshot files
Thanks in advance.

Regards,
Markus (T)
.
Image

dariof
Posts: 12
Joined: Tue Oct 15, 2013 1:50 pm

Re: Menu path change different software version

Post by dariof » Thu Nov 14, 2013 5:35 pm

Snapshot in attach.
Thanks

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

Re: Menu path change different software version

Post by Support Team » Mon Nov 18, 2013 9:03 pm

Unfortunately, there is currently no way to disable the index alone. What you can do, is modifing the RanoreXPath generation parameters (supported since Ranorex 4.1.0) to not include tree items at all. I'm not sure that is always OK for your application :?

You can do that by opening the Ranorex Settings, selecting the "Advanced" tab, and clicking on "Edit Path Build Options..." (also see corresponding section in the user guide).
Now, in order to not include menu items in the path at all, scroll down the list until you reach "treeitem" and give it a value of "0". From now on, the automatically generated RanoreXPaths will not contain tree items any more.

If you are not satisfied with the outcome, you can always reset the parameters using the "Restore Defaults" button in the RanoreXPath Build Options dialog.

Regards,
Alex
Ranorex Team
.
Image