Can't i use ChildIndex to identify a object

Ask general questions here.
marcushe
Posts: 112
Joined: Tue Apr 14, 2009 6:38 am

Can't i use ChildIndex to identify a object

Post by marcushe » Wed Jul 29, 2009 4:15 am

Environment:Ranorex2.1.2.6480,Win7,AdobeReader
Step: 1. Open Aodbe
2. Select and click Help menu
3. Select About and click
My job will across national languages ,therefore ,i can't use text to identify a menuitem,suck like 'About'. On Adobe Reader menu ,these objects has no controlid or controlname, I want to click the menuitem by its childindex. childindex of Help is 6, childindex of About is 2. When i use childindex , script will fail unless i use AccessibleName or text.
On diffrient languages, shortcut key may be diffrient,like Ctrl+O on US, Ctrol+?? on Br/GR/IT
Can't i use childindex to click a menu?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Can't i use ChildIndex to identify a object

Post by Support Team » Wed Jul 29, 2009 8:40 am

Hi marcushe,
set the index within the brackets of the menu item in RxPath like:

/form[@title='Untitled - Notepad']/menubar[@accessiblename='Application']/menuitem[2]

Regards,
Christian
Support Team

marcushe
Posts: 112
Joined: Tue Apr 14, 2009 6:38 am

Re: Can't i use ChildIndex to identify a object

Post by marcushe » Thu Jul 30, 2009 1:57 am

Thanks guys, a little question:
When i use RanorexSpy to capture the menuitem , it is based on 0.Such as File,View,Window, File's childindex is 0,View's is 1. Once i want to click the first one in script,i must use in Rxpath ....Application/menuitem[1] , instead of ....Application/menuitem[0].

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Can't i use ChildIndex to identify a object

Post by Support Team » Thu Jul 30, 2009 8:40 am

The RxPath is based on the XML Path Language (XPath). Indexing in XPath begins from 1 instead of 0 e.g. in the CSharp language. So 'element.Children[]' indexing is programming language dependent.

Additional info:
The index in RxPath references to the corresponding element type e.g. menuitem[2] is the second menuitem in the actual tree level. Element.ChildIndex instead counts from zero and does not care about the type of element, it just returns the index of the corresponding child in its parent.

Regards,
Christian
Support Team