After a while of using Ranorex Studio I began to notice that a lot of my repository items have a RanoreXPath something like:
.//container/container[3]/[@type="Example"].
But because the index 3 changed often I figured-out it was possible to do something like:
.//container/?/[@text="Click here"].
And this will create a repo item for something that has the text value of "Click here" and ignore the container index.
So, in general I'm wondering if there's a way to make this even more broad and general? Like, is there a way to create a repository item that clicks on any element in the repo that has the text "Click here"?
And I'm also wondering if there are any resources or links to resources you might have about advanced RanoreXPath customization and all of the different options that can be used. Right now I know how to replace @type with @text and it works, and so I'm wondering what else I can use @ for.
Thank you.
How to create repository items with a general path?
Re: How to create repository items with a general path?
Hi,
There is number of webinars and blog posts found at Ranorex
website:
https://www.ranorex.com/resources/
https://www.ranorex.com/automated-testing-webinars/
https://www.ranorex.com/blog/
Simply search for xpath-related articles and videos.
Generally speaking, you can use any attribute available in Spy. You can even use logical operators 'and' and 'or', like
.//container/?/[@text="Click here" or @text="Click there"]
.//container/?/[@text="Click here" and @visible="True"]
Just be careful about generalizing the xpath too much, because it could result in multiple found elements (some of them may be invisible or irrelevant). In case of multiple found elements, Ranorex will always pick and use the first one found, where the first one does not necessarily be the one you want
There is number of webinars and blog posts found at Ranorex
website:
https://www.ranorex.com/resources/
https://www.ranorex.com/automated-testing-webinars/
https://www.ranorex.com/blog/
Simply search for xpath-related articles and videos.
Generally speaking, you can use any attribute available in Spy. You can even use logical operators 'and' and 'or', like
.//container/?/[@text="Click here" or @text="Click there"]
.//container/?/[@text="Click here" and @visible="True"]
Just be careful about generalizing the xpath too much, because it could result in multiple found elements (some of them may be invisible or irrelevant). In case of multiple found elements, Ranorex will always pick and use the first one found, where the first one does not necessarily be the one you want
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
-
- Certified Professional
- Posts: 455
- Joined: Tue Feb 18, 2014 2:14 pm
- Location: Co Louth, Ireland
- Contact:
Re: How to create repository items with a general path?
In addition to the helpful links odklizec gave you, you might find this section of the Ranorex User Guide helpful: https://www.ranorex.com/help/latest/ran ... roduction/
Re: How to create repository items with a general path?
I recommend you to use repository variables:
https://www.ranorex.com/help/latest/ran ... n-testing/
https://www.ranorex.com/help/latest/ran ... n-testing/