Technology specific object identification, supported applications, web technologies, and 3rd party controls.
-
rba
- Posts: 1
- Joined: Wed Apr 24, 2019 3:44 pm
Post
by rba » Wed Apr 24, 2019 3:47 pm
Hello,
I have this kind of XPath that I would like to convert into Ranorex:
Code: Select all
//div[@data-internalname='0_cell' and contains(.//span,'Logistics')]
It seems that Ranonrex does not support the contains() function. Is there a way to select a div that contains a span having some text in a "ranorex way"?
Thanks and best regards,
Raphaël
-
qwertzu
- Posts: 284
- Joined: Wed Jan 25, 2017 11:08 am
Post
by qwertzu » Thu Apr 25, 2019 2:06 pm
Hi Raphael,
So, if I understand you correctly, you're trying to find a RanoreXPath to a specific span tag below a div tag?
What path does Ranorex Spy give you when tracking the element?
Please post a
Ranorex Snapshot of this element so the community can help you.
regards, qwertzu
-
odklizec
- Ranorex Guru

- Posts: 7469
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Tue Apr 30, 2019 12:40 pm
Hi,
I think you are looking for xpath relationship operators. If the span tag is located under div tag you want to localize, you can use something like this:
//span[@innertext='Logistics']/ancestor::div[@data-internalname='0_cell']
But as mentioned by qwertzu, it would be much easier to provide sensible answer with available Ranorex snapshot

For more RanoreXPath tips and tricks, follow this blog post:
https://www.ranorex.com/blog/ranorexpat ... nd-tricks/
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
-
Jewell26
- Posts: 1
- Joined: Fri May 03, 2019 6:47 am
Post
by Jewell26 » Tue May 14, 2019 6:08 am
1 Overview. The contains() function tests whether a string attribute contains a specific string (case-insensitive) as a sub-string.
2 Example. This query returns all the customers from which the name contains the string an : //Sales.Customer[contains(Name, 'an')] Java. Copy.
Last edited by
Jewell26 on Wed May 15, 2019 12:47 pm, edited 1 time in total.
-
odklizec
- Ranorex Guru

- Posts: 7469
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Wed May 15, 2019 7:53 am
Jewell26 wrote: ↑Tue May 14, 2019 6:08 am
2 Example. This query returns all the customers from which the name contains the string an : //Sales.Customer[contains(Name, 'an')] Java. Copy.
As mentioned, 'Contains' is currently not supported by Ranorex xpaths. However, the same could be achieved by regex, which is supported by Ranorex. The xpath in Ranorex could look like this:
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
-
GordonRamsay
- Posts: 13
- Joined: Fri Feb 15, 2019 4:25 am
Post
by GordonRamsay » Thu May 28, 2020 9:33 am
I have come across situations where I would like contains instead of regex.
E.g. if I wanted to search for an element that contains the string
Then using
on the element, it would simply not match, e.g.
//text[@text~'^^test^^']
Ofcourse, i'm sure it's easy to write a usercode method for this, however I would really like this in RanoreXpath
A clean Ranorex test suite will get you clean results.
-
odklizec
- Ranorex Guru

- Posts: 7469
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Thu May 28, 2020 9:48 am
Hi,
You must escape the '^' character, because it's a special regex character. This xpath should work...
//text[@text~'\^\^test\^\^']
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
-
GordonRamsay
- Posts: 13
- Joined: Fri Feb 15, 2019 4:25 am
Post
by GordonRamsay » Fri May 29, 2020 2:09 pm
That's true, but what if I want my repo item to match the value of a variable that I have? Is there a way to escape the variable?
For example, a variable that I do not know what will be until runtime
A clean Ranorex test suite will get you clean results.
-
odklizec
- Ranorex Guru

- Posts: 7469
- Joined: Mon Aug 13, 2012 9:54 am
- Location: Zilina, Slovakia
Post
by odklizec » Fri May 29, 2020 2:57 pm
Hi,
As far as I know, the only solution is to escape the variable in code, as described here:
https://www.ranorex.com/forum/viewtopic ... 243#p21235
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