Hello everyone,
I've just come across a rather obstinate problem concerning ranoreXpaths. The following screenshot shows the relevant part of the application I'm working on.
I'm trying to create a ranoreXpath which identifies those Containers 'ColumnCell' inside the IosScrollView which have children. Those without children are not showing up on the UI of the application I'm working. The ranoreXpath will then be used in conjunction with a repository variable to identify one of the visible containers by its sequence on the UI.
As an example, the following ranoreXpath would be used if there were no empty containers at all: iosscrollview/container[@platformclass='ColumnCell'][$fieldrowNumber].
- tgroeger
Identifying elements without children via RanoreXpath
Identifying elements without children via RanoreXpath
You do not have the required permissions to view the files attached to this post.
Re: Identifying elements without children via RanoreXpath
If you want only the containers called "ColumnCell" that have children, the following should work:
This will first get all containers with platformclass='ColumnCell', then all element children of those containers (this weeds out the ColumnCells that don't have children because no element will be found under the container), then goes back to the parent container and finds the one with the fieldrownumber indicated.
See if it works. If it does, great! If not, try to tweak it some and see if that works. If you get stumped, let us now how it isn't working and maybe we can help some more.
Code: Select all
iosscrollview/container[@platformclass='ColumnCell']/element/parent::container[$fieldrowNumber]
See if it works. If it does, great! If not, try to tweak it some and see if that works. If you get stumped, let us now how it isn't working and maybe we can help some more.
Shortcuts usually aren't...
Re: Identifying elements without children via RanoreXpath
The path you specified returns the parent of the first element inside any ColumnCell.
Example:
ColumnCell
- element
- element
ColumnCell
- element
- element
- element
ColumnCell
ColumnCell
- element
Using a variation of your path to get the fourth ColumnCell by using the number 4 as $fieldrowNumber instead returns the parent of the fourth contained element, which would be the second ColumnCell.
So, sadly, this does not help me.
Example:
ColumnCell
- element
- element
ColumnCell
- element
- element
- element
ColumnCell
ColumnCell
- element
Using a variation of your path to get the fourth ColumnCell by using the number 4 as $fieldrowNumber instead returns the parent of the fourth contained element, which would be the second ColumnCell.
Code: Select all
iosscrollview/container[@platformclass='ColumnCell']/element/parent::container[][$fieldrowNumber]
Re: Identifying elements without children via RanoreXpath
I might have misunderstood what you were looking for.
You said that those without children do not show up. Could you instead use the Visible attribute?
Something like:
And maybe my previous path should have been:
Like I said, you should play with different paths with your application.
Could you post a snapshot of your application (if allowed)? For information on snapshots, see the following:
http://www.ranorex.com/support/user-gui ... files.html
You said that those without children do not show up. Could you instead use the Visible attribute?
Something like:
Code: Select all
iosscrollview/container[@platformclass='ColumnCell' and @visible='True']
And maybe my previous path should have been:
Code: Select all
iosscrollview/container[@platformclass='ColumnCell'][$fieldrowNumber]/element/parent::container
Could you post a snapshot of your application (if allowed)? For information on snapshots, see the following:
http://www.ranorex.com/support/user-gui ... files.html
Shortcuts usually aren't...
Re: Identifying elements without children via RanoreXpath
Unfortunately even though those elements aren't discernible on the UI they are nevertheless "Visible" as far as Ranorex is concerned, as can be seen on the screenshot I provided (Invisible items show up as greyed out in the spy).
This ranoreXpath will again, sadly not give me what I need. It will instead give me, out of every ColumnCell, the one with the index $fieldrowNumber and then try to find contained elements. As I've initially written, I need a path that gets any ColumnCell with children a way that I can append a repository variable to call upon those by their sequence.
I appreciate your help and wouldn't be here asking for it if I hadn't tried quite a few ways to do exactly that. If there is another way to identify the elements I need without finding some way to identify elements with or without children I was not able to find it, which is why I'm here asking for a way to do just that.
Code: Select all
iosscrollview/container[@platformclass='ColumnCell'][$fieldrowNumber]/element/parent::container
I appreciate your help and wouldn't be here asking for it if I hadn't tried quite a few ways to do exactly that. If there is another way to identify the elements I need without finding some way to identify elements with or without children I was not able to find it, which is why I'm here asking for a way to do just that.
Re: Identifying elements without children via RanoreXpath
Hi tgroeger,
It would be much easier to help you, if you provide us with the snapshot file of the element in question, as suggested by krstcs.
If I understand you right, then all you need is to identify all non-empty "ColumnCell' elements?
What about this path? This should return ALL nonempty "ColumnCell" elements.
I tried to simulate you problem with the KeePass demo and the above path works quite well for me. It identifies only the ColumnCells with child elements...
It would be much easier to help you, if you provide us with the snapshot file of the element in question, as suggested by krstcs.
If I understand you right, then all you need is to identify all non-empty "ColumnCell' elements?
What about this path? This should return ALL nonempty "ColumnCell" elements.
Code: Select all
iosscrollview/container[@platformclass='ColumnCell']/element/parent::container[@platformclass='ColumnCell']
You do not have the required permissions to view the files attached to this post.
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
Re: Identifying elements without children via RanoreXpath
Thank you for your help. I'm unable to provide you with the Snapshot file, because I'm not allowed to do so.
Your path does generally identify the elements I'm searching and was one of the things I've tried beforehand. In practice when using this path I'm unable to access any but the very first ColumnCell that is identified by using it, which is where the problems begin.
I have, before starting this thread, tried three variations of the path you provided which didn't enable me to do what I wanted:
This, as stated in an earlier post only enumerates ANY ColumnCell and then searches for contained elements and afterwards itself again, leading to an enumeration of ANY ColumnCell, and not only those with children.
This enumerates any contained elements in any ColumnCell and returns its parent, leading to a false mapping. Instead of returning the second ColumnCell with children when being supplied with "$fieldrowNumber = 2" it instead would return the parent of the second child-element of ANY ColumnCell.
This again does the same as the one before it.
Your path does generally identify the elements I'm searching and was one of the things I've tried beforehand. In practice when using this path I'm unable to access any but the very first ColumnCell that is identified by using it, which is where the problems begin.
I have, before starting this thread, tried three variations of the path you provided which didn't enable me to do what I wanted:
Code: Select all
iosscrollview/container[@platformclass='ColumnCell'][$fieldrowNumber]/element/parent::container[@platformclass='ColumnCell']
Code: Select all
iosscrollview/container[@platformclass='ColumnCell']/element[][$fieldrowNumber]/parent::container[@platformclass='ColumnCell']
Code: Select all
iosscrollview/container[@platformclass='ColumnCell']/element/parent::container[@platformclass='ColumnCell'][$fieldrowNumber]
Re: Identifying elements without children via RanoreXpath
Without the snapshot, it's really hard to tell what's wrong with your paths or the paths we suggested. OK, would not it be easier for you to create a method with foreach loop that would go through all ColumnCell elements, check the number of their children and do whatever you want to do only with those with non-zero child count?
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
Re: Identifying elements without children via RanoreXpath
It would be a lot easier, provided I only wanted to use that path or the objects a few times in single instances of recordings and/or code. But the path is used as a basepath to specify children inside of specific ColumnCells and subsequently used to define actions on them in the form of recordings.
Not being able to rely on the sole path would mean having to add custom code to quite a few actions and having to add that very same code to any new action I will define in the future, which are and will be quite a few.
Unfortunately it seems that there's no way around it.
Not being able to rely on the sole path would mean having to add custom code to quite a few actions and having to add that very same code to any new action I will define in the future, which are and will be quite a few.
Unfortunately it seems that there's no way around it.