Ranorex Relative XPath

Ask general questions here.
Punashri M S
Posts: 42
Joined: Tue Jan 30, 2018 12:56 pm

Ranorex Relative XPath

Post by Punashri M S » Tue Jun 25, 2019 8:43 am

Hello All,

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

Thanks in advnace.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex Relative XPath

Post by odklizec » Tue Jun 25, 2019 8:45 am

Hi,

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

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Punashri M S
Posts: 42
Joined: Tue Jan 30, 2018 12:56 pm

Re: Ranorex Relative XPath

Post by Punashri M S » Tue Jun 25, 2019 11:30 am

please find the attached sanpshot.
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex Relative XPath

Post by odklizec » Tue Jun 25, 2019 11:38 am

Hi,

Thanks. Now what exactly you want to know? "Relative xpath" is somewhat broad description of the problem ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Punashri M S
Posts: 42
Joined: Tue Jan 30, 2018 12:56 pm

Re: Ranorex Relative XPath

Post by Punashri M S » Tue Jun 25, 2019 11:51 am

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']

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex Relative XPath

Post by odklizec » Tue Jun 25, 2019 12:12 pm

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']
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration