Page 1 of 1

x path not working in ranorex spy

Posted: Wed Jun 14, 2017 8:04 am
by fleipold
I wanted to change the xpath of a element in that way that ranorex selects the root element depending on criteria s of a child element. I checked the xpath with multiple sites with a simple xml and it should work.
But in the ranorex spy the xpath is marked as invalid without showing a error message.


XPATH
//form[//text[@AccessibleName='Mark mixture as surface ?']]

Simple xml
<root xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<actors>
<actor id="1">Christian Bale</actor>
<actor id="2">Liam Neeson</actor>
<actor id="3">Michael Caine</actor>
</actors>
<foo:singers>
<foo:singer id="4">Tom Waits</foo:singer>
<foo:singer id="5">B.B. King</foo:singer>
<foo:singer id="6">Ray Charles</foo:singer>
</foo:singers>
<form>
<text accessibleName="Mark mixture as surface ?">
</text>
</form>
</root>

Re: x path not working in ranorex spy

Posted: Wed Jun 14, 2017 8:09 am
by odklizec
Hi,

This is not valid xpath. You need to use xpath like this:

Code: Select all

/form//text[@AccessibleName='Mark mixture as surface ?']

Re: x path not working in ranorex spy

Posted: Wed Jun 14, 2017 8:58 am
by ahoisl
odklizec wrote:This is not valid xpath.
Actually, it is a valid XPath according to the W3C XPath specification, but not a valid RanoreXPath. There are differences between XPath and RanoreXPath, since RanoreXPath is designed to work for more technologies than just web.

One difference is that RanoreXPath does not support nested queries, that's why you have to rewrite nested queries as odklizec explained.

Regards,
Alex
Ranorex Team

Re: x path not working in ranorex spy

Posted: Wed Jun 14, 2017 9:24 am
by fleipold
Hmm, ok.
Is there a documentation which xpath querries are supported by ranorex xpath ?
Regards
Florian

Re: x path not working in ranorex spy

Posted: Wed Jun 14, 2017 9:46 am
by ahoisl
The documentation in the user guide should explain all functionality RanoreXPath supports (except for a description of non-abbreviated "axes" like "following-sibling" or "ancestor"):
https://www.ranorex.com/support/user-gu ... html#c3296

Regards,
Alex
Ranorex Team

Re: x path not working in ranorex spy

Posted: Wed Jun 14, 2017 1:43 pm
by Vaughan.Douglas
Nested queries are something that I would really like to see incorporated into RxPath functionality. Please vote for it over at user voice

Re: x path not working in ranorex spy

Posted: Wed Jun 14, 2017 3:28 pm
by fleipold
Interesting is that xpath expressions like
\\form\\component\\button seem to work in some cases. Its not not that the tool cannot execute that. Its just not working consistent

Re: x path not working in ranorex spy

Posted: Wed Jun 14, 2017 3:39 pm
by Vaughan.Douglas
fleipold wrote:Interesting is that xpath expressions like
\\form\\component\\button seem to work in some cases. Its not not that the tool cannot execute that. Its just not working consistent
if you get an error saying something like "...[the object} is no button" Try changing \\form\\component\\button to \\form\\component\\buttontag

Another point is that I'll place the form object itself in the repo as a rooted folder and add descendants to that hierarchy.

Re: x path not working in ranorex spy

Posted: Wed Jun 14, 2017 9:39 pm
by ahoisl
fleipold wrote:Interesting is that xpath expressions like
\\form\\component\\button seem to work in some cases. Its not not that the tool cannot execute that. Its just not working consistent
This path is very unspecific with all the "//" in there, so depending on the number of open applications, it could take a long time (even minutes) to search for that path. Consequently, you may need a high timeout value or a more specific path.

You can easily check if a path returns the correct element by pasting it into the path search text box in Ranorex Spy.

Regards,
Alex
Ranorex Team