Use xPath instead of Full xpath

Ask general questions here.
sarchana
Posts: 3
Joined: Wed Jun 24, 2020 1:16 pm

Use xPath instead of Full xpath

Post by sarchana » Thu Oct 07, 2021 3:19 pm

Hi,

I would like to know if it is possible to use the Xpath instead of Full xpath while capturing the UI.


Full Xpath : /html/body/div[1]/div/div/div[1]/main/div/div[2]/div/div/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[1]/div/div/div[2]/div/div[2]/div

Xpath:
//*[@id="3748444"]/div/div[1]/div/div/div[1]/div/div/div[2]/div/div[2]/div

As we have defined an object Id in the xpath, I would like to know how can I use the xpath instead of Full xpath?

Please advice

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

Re: Use xPath instead of Full xpath

Post by odklizec » Thu Oct 07, 2021 3:41 pm

Hi,

The best you can do, is to post a Ranorex snapshot (NOT screenshot), so we can recommend you the best xpath for your needs. Without knowing the context, it's pretty hard to suggest anything reliable. Generally speaking, both xpaths are fragile and will most probably fail in future. You should get rid of all indexes and find some usable attributes (like class or innertext) or use xpath relationship operators, which can make your xpath much more stable. But as mentioned, without snapshot, it's impossible to suggest anything reliable ;)
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

sarchana
Posts: 3
Joined: Wed Jun 24, 2020 1:16 pm

Re: Use xPath instead of Full xpath

Post by sarchana » Fri Oct 08, 2021 7:58 am

HI,

Thank you for your quick response.

Attached the snapshot could you please advice. We have an Inner text attribute, I would also like to use some other attributes additionally.

As AUT has frequent change in the Xpath thats why I was thinking if I can use the Id as an reference attribute.

Please advice
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: Use xPath instead of Full xpath

Post by odklizec » Fri Oct 08, 2021 8:13 am

Hi,

Thanks for the snapshot. As I've suspected, there is plenty of attributes to use :) If I were in your shoes, I would use the xpath like this:
/dom[@domain='devfsaa.de.kpmgsofy.com']//div[#'app']//div[@class~'s-tab']/div[@title='Overview']
What is the xpath returned by the Tracking/Recording tool?

If you are not happy with the default generated xpath, you can change the way the xpath is generated by editing the xpath weight. Please check this user guide chapter and blog post:
https://www.ranorex.com/help/latest/ran ... e-weights/
https://www.ranorex.com/blog/automated- ... namic-ids/
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