Dynamic xpath Determination

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
remkobol
Posts: 3
Joined: Wed Jul 04, 2018 2:56 pm

Dynamic xpath Determination

Post by remkobol » Mon Nov 19, 2018 1:56 pm

Hi,
When i use XML Spy to determine an specific object in my application (Java application) it returns the following:

/form[@type='AuthorStudio']/container[@name='contentPane']/container[@name='hsplitPane']/container[@name='leftComponent']/container[@name='tabDock']/container[11]/container[@type='XVJViewport']/tree[@type='XVTree']//treeitem[@text~'^users_2450_2500:\ Leidings']

This object is dynamically created during a test, so the container (now 11) will be different during the next test.

The object mentioned above is active on my screen, but how can i determine before my next test is running the new xpath definition, because it is different now.

in general steps to be executed:
1) determine the xpath for the active element on my screen during test (just like xml spy is doing)
2) next test steps can use the real active xpath as it has been determined
3) next testrun starts with determination of active object.


thx. Remko

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

Re: Dynamic xpath Determination

Post by odklizec » Mon Nov 19, 2018 2:13 pm

Hi,

Could you please post a Ranorex snapshot (NOT screesnhot!) of the problematic element, ideally, two snapshots from different runs?

At next, in most cases (but not always), it's safe to simply remove indexes from the xpath. The rest of the xpath you posted looks quite descriptive, so you I think you can freely remove the index. But after you do it, re-check if the xpath returns correct (and unique) element.

And finally, I would suggest you to read this blog about automating apps with dynamic IDs...
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

remkobol
Posts: 3
Joined: Wed Jul 04, 2018 2:56 pm

Re: Dynamic xpath Determination

Post by remkobol » Mon Nov 19, 2018 2:19 pm

Hi,

run 1:
/form[@type='AuthorStudio']/container[@name='contentPane']/container[@name='hsplitPane']/container[@name='leftComponent']/container[@name='tabDock']/container[11]/container[@type='XVJViewport']/tree[@type='XVTree']//treeitem[@text~'^users_2450_2500:\ Leidings']

run 2:
/form[@type='AuthorStudio']/container[@name='contentPane']/container[@name='hsplitPane']/container[@name='leftComponent']/container[@name='tabDock']/container[12]/container[@type='XVJViewport']/tree[@type='XVTree']//treeitem[@text~'^users_2450_2500:\ Leidings']

so container will change per run
with removing the index:

/form[@type='AuthorStudio']/container[@name='contentPane']/container[@name='hsplitPane']/container[@name='leftComponent']/container[@name='tabDock']/container/container[@type='XVJViewport']/tree[@type='XVTree']//treeitem[@text~'^users_2450_2500:\ Leidings']
the object could not be found anymore

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

Re: Dynamic xpath Determination

Post by odklizec » Mon Nov 19, 2018 2:22 pm

Hi,

By snapshot, I meant this:
www.ranorex.com/support/user-guide-20/l ... files.html
Please post the snapshot, so I, or anyone else here, can suggest the best solution.
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

remkobol
Posts: 3
Joined: Wed Jul 04, 2018 2:56 pm

Re: Dynamic xpath Determination

Post by remkobol » Mon Nov 19, 2018 2:32 pm

snapshot is 'not' possible, it will contain all data from the database (Gb's)

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

Re: Dynamic xpath Determination

Post by odklizec » Mon Nov 19, 2018 2:42 pm

Hi,

Well, I'm afraid, that without snapshot, there is nothing else I can do for you. You can still contact Ranorex support (via their support form) and request a remote session with them. Good luck.
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

Bishikh
Posts: 1
Joined: Tue Jul 16, 2019 1:52 pm

Re: Dynamic xpath Determination

Post by Bishikh » Tue Jul 16, 2019 1:58 pm

Hello Team,

I am also facing the same issue while creating dynamic path for the click of one of the buttons. Please find the snapshot of the application.

Please let me know how to create dynamic Ranorex xpath for the unique feature identifier button.

Any help will be greatly appreciated.

Thanks and regards
Bishikh Pal
Attachments
UniqueFeatureIdentifier.PNG
UniqueFeatureIdentifier.PNG (87.45 KiB) Viewed 279 times
ClickUniqueFeatureIdentifier.rxsnp
(82.87 KiB) Downloaded 5 times

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

Re: Dynamic xpath Determination

Post by odklizec » Wed Jul 17, 2019 8:08 am

Hi,

I'm not exactly sure what's the problem with creating xpath in your case? Basically, you can identify the button by its Text attribute, so the xpath could look like this:
/form[@title='Process Information']//button[@text='Unique Feature Identifier']
Or am I missing something important? Please describe, in more details, what exactly is your problem? Thanks.
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

manish
Posts: 46
Joined: Fri Aug 10, 2018 12:46 pm

Re: Dynamic xpath Determination

Post by manish » Wed Jul 17, 2019 3:06 pm

Hi remkobol,

Could you try this
/form[@type='AuthorStudio']/container[@name='contentPane']/container[@name='hsplitPane']/container[@name='leftComponent']/container[@name='tabDock']/?/container[@type='XVJViewport']/tree[@type='XVTree']//treeitem[@text~'^users_2450_2500:\ Leidings']
I guess this should help you out

BR
Manish
Last edited by manish on Wed Jul 17, 2019 3:12 pm, edited 1 time in total.

manish
Posts: 46
Joined: Fri Aug 10, 2018 12:46 pm

Re: Dynamic xpath Determination

Post by manish » Wed Jul 17, 2019 3:11 pm

Hi Bishikh,

Can you try the below Xpath:

/form[@title='Process Information']/.//element[@accessiblename='UGS::UICOMP_button']/buttton[@accessiblename='Unique Feature Identifier']

BR
Manish

ugentudepti
Posts: 2
Joined: Thu Aug 29, 2019 8:40 pm

Re: Dynamic xpath Determination

Post by ugentudepti » Mon Sep 02, 2019 10:51 am

snapshot is 'not' possible, it will contain all data from the database (Gb's)
Ücretsiz PDF belgeleri
Gratis PDF-dokumenter
Darmowe dokumenty PDF
Gratis PDF Documenten

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

Re: Dynamic xpath Determination

Post by odklizec » Mon Sep 02, 2019 11:53 am

Hi,

Unfortunately, it's impossible to provide a reasonable help without snapshot, and somewhat more detailed description of your problem. Generally speaking, you must edit recorded xpaths to make them independent from dynamic changes. So in your case, simply remove index of problematic container, or replace it with something else. Just make sure the xpath without index number still returns desired and unique element.
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