Limiting search depth

Best practices, code snippets for common functionality, examples, and guidelines.
MichielV
Posts: 17
Joined: Fri Sep 07, 2018 8:12 am

Limiting search depth

Post by MichielV » Fri Nov 09, 2018 10:12 am

We are building tests for a rather large WPF application (thousands of elements, 100+ nested levels) using ranorex.

In order to simplify the paths, we often use the "any descendants" vector //. This however has the downside that it significantly slows down the automation and spy because the entire AUT is traversed for each search.
We have been able to improve the performance by using a sequence of wildcards such as /?/?/?/?/?/?/?/?/?/?/ instead of //. However, this makes the paths less user-friendly to read.

So my questions are:
- is there any shorthand to combine multiple wildcards, e.g. /?[10]/ would search the first 10 levels from the root.
- is there an expression to get the first descendant encountered, that would stop further scanning of the application?
- any other recommendations to improve performance while maintaining an acceptible level of robustness?

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

Re: Limiting search depth

Post by odklizec » Fri Nov 09, 2018 10:23 am

Hi,

I'm afraid, the answer on first two questions is "no". There is no such functionality in Ranorex xpaths. You can create a feature request here:
https://uservoice.ranorex.com/forums/15 ... ve-ranorex

Probably the only way, how to improve the speed of element search, is to add some additional (ideally unique) elements to the xpath. E.g. search and select some additional "key" elements in the xpath and add them to the final xpath. Even if there are no elements with unique IDs, you can always find some elements with unique Class, InnerText or similar attributes. Additional elements could significantly improve the speed of search.
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

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Limiting search depth

Post by krstcs » Mon Nov 12, 2018 3:30 pm

You should not use the "any descendants" vector ("//") unless absolutely necessary because this forces Ranorex to search the whole tree, which takes a lot of time depending on the system/application under test.

My suggestion would be to create rooted folders at intermediate levels that are pathed. This will allow Ranorex to only search for a limited number of elements instead of the whole tree. Your repo would look like:

MyApp -> form[@title='MyApp']
..RootedFolder1 -> */div[@id='123']
....Element1 -> */button[@title='Ok']
....Element2 -> */button[@title='Cancel']

Keep elements that are under the same parent in the same folder, then you only have to change the parent folder when the path changes and all children will have the new intermediate path.
Shortcuts usually aren't...

David Zita
Posts: 30
Joined: Thu Mar 31, 2016 1:20 pm

Re: Limiting search depth

Post by David Zita » Fri Oct 11, 2019 12:48 pm

I have a question similar to the topic so I will post it here.
Is there any absolute depth limitation in the XPath? I have the following XPath defined:

Code: Select all

/?/dom[@caption~'^'+'Test610_Ranorex1'+'(\.template)?$' or @page='Test610_Ranorex1']//div[#'editorLayoutContainer']//div[#'editorContainer']//div[#'editor']
And it does not find the final div. The Spy highlights the #editorContainter and does not continue deeper. If I however, change the last // to 7 div tags, it works. Is there any limit that could be increased?
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: Limiting search depth

Post by odklizec » Fri Oct 11, 2019 12:56 pm

Hi,

Could you please post a Ranorex snapshot (NOT screenshot) of the tested app? It would help us to analyze the problem and eventually, provide a reasonable answer.

Also, what version of Ranorex do you use? The most recent is 9.2.1. If you are using something older (like Rx8 or lower), you should definitely try the most recent one, as the old versions could be affected by a bug, which may already be fixed in later versions. So please make sure, the problem is reproducible also with most recent 9.1.2. And if the problem is still reproducible, please post the app snapshot. 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

David Zita
Posts: 30
Joined: Thu Mar 31, 2016 1:20 pm

Re: Limiting search depth

Post by David Zita » Mon Oct 14, 2019 9:01 am

Snapshot attached. I am using Ranorex 9.1.2.
Unfortunatelly, the Spy in Snapshot does not behave the same as the Spy in Live mode, see attached gif. Also I should mention that the AUT in this case is a Java app using JxBrowser. I can also open the same page in regular browser (Chrome, Edge etc.) and there the recognition works correctly. Could this be somehow important?
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: Limiting search depth

Post by odklizec » Mon Oct 14, 2019 9:16 am

Hi,

I don't see anything wrong in the snapshot you posted. I think you will have to contact Ranorex support and request a remote desktop with them to demonstrate the problem.

Just one thing to check. Have you created the snapshot with standalone Spy or the one started from Studio? Please make sure both Spys using the same settings!
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