x path not working in ranorex spy

Ask general questions here.
fleipold
Posts: 37
Joined: Fri Jun 09, 2017 7:04 am

x path not working in ranorex spy

Post by fleipold » Wed Jun 14, 2017 8:04 am

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>
Attachments
snapshot.rxsnp
(56.2 KiB) Downloaded 17 times

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

Re: x path not working in ranorex spy

Post by odklizec » Wed Jun 14, 2017 8:09 am

Hi,

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

Code: Select all

/form//text[@AccessibleName='Mark mixture as surface ?']
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

ahoisl
Certified Professional
Certified Professional
Posts: 125
Joined: Fri Sep 07, 2007 8:16 am

Re: x path not working in ranorex spy

Post by ahoisl » Wed Jun 14, 2017 8:58 am

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

fleipold
Posts: 37
Joined: Fri Jun 09, 2017 7:04 am

Re: x path not working in ranorex spy

Post by fleipold » Wed Jun 14, 2017 9:24 am

Hmm, ok.
Is there a documentation which xpath querries are supported by ranorex xpath ?
Regards
Florian

ahoisl
Certified Professional
Certified Professional
Posts: 125
Joined: Fri Sep 07, 2007 8:16 am

Re: x path not working in ranorex spy

Post by ahoisl » Wed Jun 14, 2017 9:46 am

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

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: x path not working in ranorex spy

Post by Vaughan.Douglas » Wed Jun 14, 2017 1:43 pm

Nested queries are something that I would really like to see incorporated into RxPath functionality. Please vote for it over at user voice
Doug Vaughan

fleipold
Posts: 37
Joined: Fri Jun 09, 2017 7:04 am

Re: x path not working in ranorex spy

Post by fleipold » Wed Jun 14, 2017 3:28 pm

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

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: x path not working in ranorex spy

Post by Vaughan.Douglas » Wed Jun 14, 2017 3:39 pm

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.
Doug Vaughan

ahoisl
Certified Professional
Certified Professional
Posts: 125
Joined: Fri Sep 07, 2007 8:16 am

Re: x path not working in ranorex spy

Post by ahoisl » Wed Jun 14, 2017 9:39 pm

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