One Xpath but two values

Best practices, code snippets for common functionality, examples, and guidelines.
Kikkaha
Posts: 11
Joined: Wed Mar 22, 2017 4:39 pm

One Xpath but two values

Post by Kikkaha » Wed Dec 06, 2017 2:38 pm

Hello everybody

the following situation:
1. I track a field (silverlight) with spy
2. I validate the content
3. a few steps later the field contains a different content
4. I want to validate the new content
but....the xpath I tracked with spy is containing the content of the validation before
If I use variables (e.g. excel sheet with 2 different contents for the same field) the test is running twice and fails(Not good)
In this case I tried to split the module and used for each module a separate Repository..--> it works fine....but....
In this way (for each module one repository) the complexity is growing enormously AND the startup of the project is very slow. (at this time I have more than 300 modules)

What can I do to validate the same field (same xpath) with more than one content??

Kind regards
Kikkaha

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: One Xpath but two values

Post by krstcs » Wed Dec 06, 2017 3:25 pm

Without more info it will be difficult to give any real meaningful help. Please always include the following:

FULL Ranorex version (currently 7.1.3 and 7.2.1 are the only versions supported)
Windows version
RanoreXPath of element in question
Ranorex Snapshot (NOT screenshot!) of element in question


My generalized suggestion, without more info, is that you should remove the content value from the XPath and make the XPath work without the field content. This is generally a better idea anyway. Your XPath should not depend on the value of a field but on other attributes because the value can and will change often in most situations.
Shortcuts usually aren't...

Kikkaha
Posts: 11
Joined: Wed Mar 22, 2017 4:39 pm

Re: One Xpath but two values

Post by Kikkaha » Wed Dec 06, 2017 3:58 pm

Windows 7 Enterprise Service Pack 1
Because our sec.-restrictions it is not possible to send a snapshot
Ranorex 7.2.1

The system is a shop floor-System.
The system includes a few process steps
for each step there is a separate view.
on each view it is possible that field contents become - while running - different values

For me it is necessary to validate the values
it is not enough to check if there is something in the Xpath available
And the question is.... is there another way to check the same Xpath with different contents without using for every module a
separate repository or not?
If not...ok...I can live with.... but how many repositories can I use in the same project????

Kind regards
Kikkaha

Kikkaha
Posts: 11
Joined: Wed Mar 22, 2017 4:39 pm

Re: One Xpath but two values

Post by Kikkaha » Wed Dec 06, 2017 4:03 pm

Here is an example of an Xpath

/dom[@domain='Example12345.com']//div[#'silverlightControlHost']/?/?/form[@name='Silverlight Control']/?/?/tabpage[@name='Zuweisung']/text[@name='Lose Produktion (1)']

And this part of the path is what I need to check
--> [@name='Lose Produktion (1)']

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: One Xpath but two values

Post by krstcs » Wed Dec 06, 2017 7:50 pm

You should not have to use multiple repositories, and I suggest not doing that because of the amount of maintenance required.

As for the XPath, the @name attribute should not be changing for a specific field. The @name attribute is intended to be static in most situations. The @value attribute should be what is changing. If the @name is changing, then you should consider it a different element.

However, without a Ranorex Snapshot there is really no way that any of us can help you figure this out because we have no way to understand the structure of the application you are testing.

As for what you are validating, do you just need to know if the element exists? Or are you checking for the specific @name attribute's value? Please give us as much info as you can.
Shortcuts usually aren't...

Kikkaha
Posts: 11
Joined: Wed Mar 22, 2017 4:39 pm

Re: One Xpath but two values

Post by Kikkaha » Thu Dec 07, 2017 8:13 am

I wrote:
--> on each view it is possible that field contents become - while running - different values

For me it is necessary to validate the values
it is not enough to check if there is something in the Xpath available <--

Thereafter you ask:
--> As for what you are validating, do you just need to know if the element exists? Or are you checking for the specific @name attribute's value<--

I have no idea how to describe what I need if that text above is not clear enough.
So... I think we can stop this discussion.

Thanks for trying to help me.
Have a nice day
Kikkaha

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

Re: One Xpath but two values

Post by odklizec » Thu Dec 07, 2017 8:38 am

Hi Kikkaha,

As mentioned by Kelly, it would be much easier to help to see a Ranorex snapshot with problematic values. Could you please generate and upload one?

Generally speaking, what you want to achieve should be easily doable with data connector and two values. Eventually, if the two values appear in random order, you can use two values in the xpath and "OR" operator. But again, it would be much easier to provide a reasonable solution with available snapshot (or two snapshots...one per value).
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

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: One Xpath but two values

Post by krstcs » Thu Dec 07, 2017 3:35 pm

As I said, the @name attribute should not contain content values, it should be fairly stable. If that isn't the case then either your app is not coded correctly, or your app's framework does something different than every other framework out there. That is why we are asking for the Ranorex Snapshot. If you can't share the actual snapshot, you could create a demo app that demos the issue you are having and post that instead of the real one.

Otherwise, we aren't going to be able to help because we have no idea how your app is constructed and what other attributes might be available.
Shortcuts usually aren't...

loonquawl
Posts: 69
Joined: Wed Nov 22, 2017 10:08 am

Re: One Xpath but two values

Post by loonquawl » Thu Feb 01, 2018 9:24 am

I may interject, that there seems to be some confusion in the discussion about some terms:
  • The Xpath: /dom[@domain='Example12345.com']//div[#'silverlightControlHost']/?/?/form[@name='Silverlight Control']/?/?/tabpage[@name='Zuweisung']/text[@name='Lose Produktion (1)']
  • The element in the Repository that has that Xpath. Let's call it 'Hugo'
  • The value of the key 'name' in the Xpath: in the example above its 'Lose Produktion (1)'
  • The value of the key 'Value' of Hugo: I guess that is what the helpers mean when talking about value, but i'm not sure it's what Kikkaha is talking about.
So to reiterate: the Xpath of Hugo willa always contain exacly the same thing, because it's the Xpath of Hugo.

The Xpath might point to different Textfields on screen, all of which then would be Hugo to Ranorex.

Let's pretend there is one Textfield on Screen that is Hugo, and it displays different Texts at differnt Times (easiest example: a clock). So Hugo is a clock, and Kikkaha has trouble seeing the change in time reflected in Spy (and in actual use(?)).

I would recommend turning off caching in the Repository properties, and not rely on Spy to be real time, but rather test it in a recording, stand-alone.

@Kikkaha: perhaps you know of some webpage in the public domain that has such a Textfield? Then, if the problem persists after turning off caching, you could make a sample recording of the same thing you are trying to do for your proprietary page, but for whatever, http://www.pageeverybodycanreach.org

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: One Xpath but two values

Post by Vega » Fri Feb 02, 2018 8:44 pm

As suggested, we won't be able to give super meaningful help without a snapshot of the object in question. You may want to use a variable in your Ranorex path like the below:

Code: Select all

The Xpath: /dom[@domain='Example12345.com']//div[#'silverlightControlHost']/?/?/form[@name='Silverlight Control']/?/?/tabpage[@name='Zuweisung']/text[@name='$varMyValue']
This way you can change the variable as needed to validate the change. If you want a more basic approach, you could just make the path really basic like so:

Code: Select all

The Xpath: /dom[@domain='Example12345.com']//div[#'silverlightControlHost']/?/?/form[@name='Silverlight Control']/?/?/tabpage[@name='Zuweisung']/text
This path will just look for the very first text object and not use an attribute to quantify. The above path may not work for you depending on the structure of your AUT which is why we need a snapshot.

Either way what you are asking for should be totally feasible, check out these links for some good info on leveraging RxPath:
https://www.ranorex.com/blog/ranorexpat ... nd-tricks/
https://www.ranorex.com/help/latest/ranorexpath
https://www.ranorex.com/help/latest/les ... anorexpath
https://www.ranorex.com/help/latest/les ... -edit-mode