Page 1 of 1

Ranorex Relative XPath

Posted: Tue Jun 25, 2019 8:43 am
by Punashri M S
Hello All,

Please help me to understand how can i use Relative Xpath in Ranorex?

Thanks in advnace.

Re: Ranorex Relative XPath

Posted: Tue Jun 25, 2019 8:45 am
by odklizec
Hi,

It's best to show you this on a real example. Could you please post a Ranorex snapshot (NOT screenshot) of your AUT?

Re: Ranorex Relative XPath

Posted: Tue Jun 25, 2019 11:30 am
by Punashri M S
please find the attached sanpshot.

Re: Ranorex Relative XPath

Posted: Tue Jun 25, 2019 11:38 am
by odklizec
Hi,

Thanks. Now what exactly you want to know? "Relative xpath" is somewhat broad description of the problem ;)

Re: Ranorex Relative XPath

Posted: Tue Jun 25, 2019 11:51 am
by Punashri M S
please find the Xpaths below and help me understand which one is the relative path?

1st one with double slash is a relative and 2nd one is absolute path, Am i right?

/form[@controlname='RxMainFrame']//button[@controlname='button3']

or

/form[@controlname='RxMainFrame' and @title~'^Ranorex\ Studio\ Demo\ Appli' and @processname='RxDemoApp']/tabpagelist[@controlname='RxTabcontrol' and @controlid='1' and @controltypename='TabControl']/tabpage[@controlname='RxTabObject' and @title='Object identification' and @index='6']/container[@controlname='Panel_1' and @caption='' and @controltypename='Panel']/button[@controlname='button3' and @text='Button 1' and @controltypename='Button']

Re: Ranorex Relative XPath

Posted: Tue Jun 25, 2019 12:12 pm
by odklizec
Hi,

Yes, the first one is relative. But in my opinion, such xpath is too generic and may eventually take some time to find the appropriate element.

Also, ControlName, like button3, is dangerous to use, because such names are prone to changes. So I would rather suggest to use directly "Control Text". However, in case of UI with multiple buttons featuring the same "Control Text" string, you may eventually need to use another element as an anchor.

For example, to find "Button 2" in frame "Panel_22", you can use xpath like this:
/form[@controlname='RxMainFrame']//container[@controlname='Panel_22']/button[@controltext='Button 2']