Is there a fast way to get the last child in an Xpath?
For example, If I had something like this:
UL
|--- LI
|--- LI
|--- LI
|--- LI
|--- LI
And I wanted the get the last LI(but I don't know there are 5 of them), aside from getting a count of the children for the UL object and using the var in the xpath, can I do something else that is faster?
Say something like: objLI = objUL.FindSingle("./li[$]") (I use $ in my example because it means look at end for regular expression)
Thanks,
Aracknid
Getting the last child in an XPath
Re: Getting the last child in an XPath
Get an iList of all the LIs then get the information of the last one in the list...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: Getting the last child in an XPath
Sorry, that was just a simple example I made up. I'm not actually looking for list items...
What I am looking for is the last child object within a DIV. I might be a Span, and Anchor, or possible something else.
What I am looking for is the last child object within a DIV. I might be a Span, and Anchor, or possible something else.
Re: Getting the last child in an XPath
Does something like this work for you?
Then get the last item in the AllMyChildren iList...
Code: Select all
IList<Ranorex.Unknown> AllMyChildren = MyRootElement.FindChildren<Ranorex.Unknown>();
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: Getting the last child in an XPath
Nah, that doesn't do it for me
I'm just looking for a shorter way to do this:
Aracknid

I'm just looking for a shorter way to do this:
objLI = objUL.FindSingle("./li[" & objUL.children.count & "]")Hoping there is some sort of substitute for "objUL.children.count " that can be used instead.
Aracknid
Re: Getting the last child in an XPath
Hmmm, yet again I guess I don't have the right answer for you...
What is the reason why getting an iList of all the children objects of the root object then getting the last one from there does not work for you? In theory (in my mind) it should suffice...
What is the reason why getting an iList of all the children objects of the root object then getting the last one from there does not work for you? In theory (in my mind) it should suffice...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: Getting the last child in an XPath
I've already got a way to do it. I'm just lazy and hoping to type less. 

Re: Getting the last child in an XPath
Ha! A true test automation expert hard at work!!!I'm just lazy and hoping to type less

A man after my own heart....
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Getting the last child in an XPath
Currently, there is no built-in function in RanoreXPath to specify the last element, but we have that feature on our roadmap together with a few other useful XPath operators that are currently not available in RanoreXPath.
Regards,
Alex
Ranorex Team
Regards,
Alex
Ranorex Team