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: 4041
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: 4041
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: 4041
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