Page 1 of 1

Can't i use ChildIndex to identify a object

Posted: Wed Jul 29, 2009 4:15 am
by marcushe
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?

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

Posted: Wed Jul 29, 2009 8:40 am
by Support Team
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

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

Posted: Thu Jul 30, 2009 1:57 am
by marcushe
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].

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

Posted: Thu Jul 30, 2009 8:40 am
by Support Team
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