Hi,
I want to get an element that points to the next row in a table on a web page, based on a text match of the previous row. I am using Visual Studio / C#.
For example,
I have the following relative path "./table/tbody/tr[@class='header']/th[@innertext='MySelectedRow']" where I am matching on the word: 'MySelectedRow'
I have tried to get the following row using this expression:
"./table/tbody/tr[@class='header']/th[@innertext='MySelectedRow']/../following-sibling::*"
Unfortunately this path matches ALL the subsequent rows instead of just the next one. Is it possible to change this to get just the NEXT row?
Regards
Mark
How do I get next row using RanoreXPath
-
- Posts: 13
- Joined: Thu Apr 15, 2010 4:34 pm
Re: How do I get next row using RanoreXPath
You could try something like this...
Dim selectedRow as Ranorex.whateveritis = "/path for matching row"
Dim row as Interger = selectedRow.Row + 1
Dim nextRow as Ranorex.whateveritis = "/path filtered on row attribute matching row integer"
Dim selectedRow as Ranorex.whateveritis = "/path for matching row"
Dim row as Interger = selectedRow.Row + 1
Dim nextRow as Ranorex.whateveritis = "/path filtered on row attribute matching row integer"
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How do I get next row using RanoreXPath
Hi,
Please also take look to following post
http://www.ranorex.com/forum/webtable-r ... t1661.html
Regards,
Peter
Ranorex Team
Please also take look to following post
http://www.ranorex.com/forum/webtable-r ... t1661.html
Regards,
Peter
Ranorex Team
-
- Posts: 13
- Joined: Thu Apr 15, 2010 4:34 pm
Re: How do I get next row using RanoreXPath
Thanks Peter and Sdaly,
I was hoping to find a solution using RanorexPath to select the row based on a match of the previous row.
Using the solution provided unfortunately I would have to modify the code, so that I:
1: Loop through all the rows in the table
2: When I find a match, then proceed to the next row and retrieve the values
Now my code is quite generic, being used on different webPages and data driven via the RxPath, therefore I would prefer to use the path to match on the row if possible, but it looks like it cannot be done.
Incidentally I cant even see how I would get the row number of a matched row without counting through all the rows till I find the match?
Mark.
I was hoping to find a solution using RanorexPath to select the row based on a match of the previous row.
Using the solution provided unfortunately I would have to modify the code, so that I:
1: Loop through all the rows in the table
2: When I find a match, then proceed to the next row and retrieve the values
Now my code is quite generic, being used on different webPages and data driven via the RxPath, therefore I would prefer to use the path to match on the row if possible, but it looks like it cannot be done.
Incidentally I cant even see how I would get the row number of a matched row without counting through all the rows till I find the match?
Mark.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How do I get next row using RanoreXPath
Hi Mark,
Sorry I read over the following line. "./table/tbody/tr[@class='header']/th[@innertext='MySelectedRow']/../following-sibling::*"
Of course it is possible to use the RxPath to get the next row, you can use your RxPath, just correct the last statement to "./table/tbody/tr[@class='header']/th[@innertext='MySelectedRow']/following-sibling::*".
Regards,
Peter
Ranorex Team
Sorry I read over the following line. "./table/tbody/tr[@class='header']/th[@innertext='MySelectedRow']/../following-sibling::*"
Of course it is possible to use the RxPath to get the next row, you can use your RxPath, just correct the last statement to "./table/tbody/tr[@class='header']/th[@innertext='MySelectedRow']/following-sibling::*".
Regards,
Peter
Ranorex Team
-
- Posts: 13
- Joined: Thu Apr 15, 2010 4:34 pm
Re: How do I get next row using RanoreXPath
HI Peter,
What you are suggesting below does not work. Try it youself.
Using the Spy tool I have an example on www.ranorex.com page.
go to this page and look at the table of items under the title: "Benefit with Ranorex".
Lets say I want to get the next row that appears under the item "Excellent Object Recognition"
I use the following path:
/dom[@caption~'^Test\ Automation\ Tools\ -\ R']/body/div[@id='page']/div[@id='container']/div[@id='Content']/div[1]/div[1]/ul/li[1]/a/b[@innertext~'^Excellent\ Object\ Recognit']/../../following-sibling::*
This path returns ALL following siblings. Show me a path that will get just the NEXT sibling?
Regards
Mark
What you are suggesting below does not work. Try it youself.
Using the Spy tool I have an example on www.ranorex.com page.
go to this page and look at the table of items under the title: "Benefit with Ranorex".
Lets say I want to get the next row that appears under the item "Excellent Object Recognition"
I use the following path:
/dom[@caption~'^Test\ Automation\ Tools\ -\ R']/body/div[@id='page']/div[@id='container']/div[@id='Content']/div[1]/div[1]/ul/li[1]/a/b[@innertext~'^Excellent\ Object\ Recognit']/../../following-sibling::*
This path returns ALL following siblings. Show me a path that will get just the NEXT sibling?
Regards
Mark
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How do I get next row using RanoreXPath
That is by design of XPath, your path matches all following siblings. Depending on the method you use to search for the path, you will get the first element (FindSingle) or all elements (Find) matching the RanoreXPath.markvanraalte wrote:This path returns ALL following siblings. Show me a path that will get just the NEXT sibling?
When you use the path in a Ranorex repository, the repository will return only the first element - and I guess that's exactly the behavior you want, right? E.g. for the example on the Ranorex web site you could use the following line of code:
Unknown nextSibling = "/dom[@caption~'^Test\ Automation\ Tools\ -\ R']/body/div[@id='page']/div[@id='container']/div[@id='Content']/div[1]/div[1]/ul/li[1]/a/b[@innertext~'^Excellent\ Object\ Recognit']/../../following-sibling::*";Regards,
Alex
Ranorex Team