RanoreXPath and following-sibling

Best practices, code snippets for common functionality, examples, and guidelines.
HansSchl
Posts: 127
Joined: Wed Sep 19, 2018 10:05 am

RanoreXPath and following-sibling

Post by HansSchl » Mon Apr 11, 2022 8:35 am

Hi,

does RanoreXPath support the next-sibling axis? Example:

Code: Select all

container/button[@text='Mark']/following-sibling::text
This is supposed to identify the text element following the button with the name from the $ButtonName variable.

The reason I am asking is because the "Robust path" which is displayed in the "Properties" is

Code: Select all

.../container/button[@commandparameter='Mark']/../../element
which is not what I would expect.

When I use RanorexSpy to find the object, I get a RanorexPath like

Code: Select all

container[2]/text[1]
. I don't know where Ranorex takes the "commandparameter" property from - Spy doesn't display it at all.

Regards
Hans

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

Re: RanoreXPath and following-sibling

Post by odklizec » Thu Apr 14, 2022 8:34 am

Hi,

Following-sibling is definitely supported by Ranorex implementation of xpath. Unfortunately, I'm not sure, what exactly you want to accomplish? Could you please post a Ranorex snapshot? The 'commandparameter' looks like something's wrong with Ranorex? If you (like me) don't like Robust path, you can turn it off in Ranorex settings...
RobustPathOff.png
You do not have the required permissions to view the files attached to this post.
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

HansSchl
Posts: 127
Joined: Wed Sep 19, 2018 10:05 am

Re: RanoreXPath and following-sibling

Post by HansSchl » Thu Apr 14, 2022 9:33 am

Hi Pavel,

unfortunately I cannot upload the snapshot (it's too complex) but I am attaching a screenshot of the part in question.
2022-04-14_10h10_19.png
The problem is that those UI elements (containers, buttons, and texts) have no proper automation ID. The text controls are next to the respective button controls, so users would perceive the buttons as labels to the text controls. I don't like this GUI design, but it is what it is.

The test must access the text control next to the button with a specific label. I cannot say in which container this control will be found, so my idea was to find the button with .../container/button[@text=$ButtonName] and then go to the next sibling, which is the text control: .../following-sibling::text. The test reads the $ButtonName from a data source, and tests all those button-text control pairs in a loop.

This works most of the time but sometimes fails, and when it fails, I get a somewhat strange timeout error in the report (see https://www.ranorex.info/invocation-did ... 21450.html), so I was wondering whether following-sibling might cause the problem. By the way, with "sometimes" I mean in a low percentage of all test executions. There is no specific test sequence which fails reliably, it just happens now and then.

Regards
Hans
You do not have the required permissions to view the files attached to this post.

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

Re: RanoreXPath and following-sibling

Post by odklizec » Thu Apr 14, 2022 10:04 am

Well, I'm using following-sibling in number of tests and I'm not experiencing any issue like you. So my guess is, that when it happens for you, the UI is not entirely loaded yet or something like this? I would suggest to add 'Create Snapshot' action before the typically failing action. The problem is, that saving snapshot may take some time, which may be just enough for UI to load completely and so the error may never appear again? :D

Unfortunately, without seeing the problem in real life, it's impossible to tell what could be wrong. I would suggest to add some Delays/WaitFor exists/notexists here or there. Also, are you experiencing this kind of issue with the same machine or it happens randomly on any computer you may try?
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

HansSchl
Posts: 127
Joined: Wed Sep 19, 2018 10:05 am

Re: RanoreXPath and following-sibling

Post by HansSchl » Thu Apr 14, 2022 10:19 am

Good ideas. I'll add delays or waits. Until then, I'll watch the test to see whether it always fails on the same machine. We have nightly tests running on two VMs.

Hans