Hello,
I have to get one cell value from a table and I don’t know how to iterate through table rows and cells. Can somebody please provide the code?
Idea is to perform a row wise check for a specific token number (column is known). If found, I have to retrieve the value of the cell which is after 3 cells to the token cell.
Please help
Table Row Iteration
Re: Table Row Iteration
Hi,
Please upload a Ranorex snapshot (NOT screenshot) of given table. Thanks.
Please upload a Ranorex snapshot (NOT screenshot) of given table. Thanks.
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: Table Row Iteration
Thank you. File Attached. Please check
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Table Row Iteration
Hi theraviz,
We can navigate to the row containing the specific token number with the example RxPath below. Just change out TOKENNUMBER with the actual number you are looking for. You can also use a repository variable here.
From here, what are you wanting to grab? I assume something from another column but in the same row. If you can specify specifically what you are trying to grab, I will be happy to provide an RxPath to do this. For example, the RxPath below points to the User cell in the same row as the token number.
I hope this helps!
Cheers,
Ned
We can navigate to the row containing the specific token number with the example RxPath below. Just change out TOKENNUMBER with the actual number you are looking for. You can also use a repository variable here.
Code: Select all
/dom[@domain='10.222.124.90']//table[#'JournalTableData']//td[@innertext='TOKENNUMBER']/parent::tr
Code: Select all
/dom[@domain='10.222.124.90']//table[#'JournalTableData']//td[@innertext='TOKENNUMBER']/parent::tr/td[@txfield='TellerId']
Cheers,
Ned
Re: Table Row Iteration
there are some code examples on validating an entire table / web table at once:
Advanced validation – entire table
Advanced validation – entire table in web
https://www.ranorex.com/help/latest/han ... -examples/
however this is for an entire table so this may be overkill for what you need. You can modify your XPath to traverse up or down the tree from the element which is known (token). I'm not sure exactly which cell you are trying to find, but I can give an example based on the snapshot:
Lets assume we know the 'From/To No.' ahead of time and we can use this to retrieve the 'Trace Number' from the same table row, here is how I would do it:
/dom[@domain='10.222.124.90']//table[#'JournalTableData']//td[@innertext='2020196560']/../td[6]
So as you can see above, we first find a td element with the innertext of '2020196560', this is our known starting point for the 'From/To No.' value. Of course this would likely be a variable within your test, but for this example I am using static values. Next you will see in the path that I am using /../td[6]. The '..' means go up the tree to the parent node which would be the table row, then /td[6] tells Ranorex to give us the 6th TD element in that row which happens to be the 'Trace Number'
hope this helps
Advanced validation – entire table
Advanced validation – entire table in web
https://www.ranorex.com/help/latest/han ... -examples/
however this is for an entire table so this may be overkill for what you need. You can modify your XPath to traverse up or down the tree from the element which is known (token). I'm not sure exactly which cell you are trying to find, but I can give an example based on the snapshot:
Lets assume we know the 'From/To No.' ahead of time and we can use this to retrieve the 'Trace Number' from the same table row, here is how I would do it:
/dom[@domain='10.222.124.90']//table[#'JournalTableData']//td[@innertext='2020196560']/../td[6]
So as you can see above, we first find a td element with the innertext of '2020196560', this is our known starting point for the 'From/To No.' value. Of course this would likely be a variable within your test, but for this example I am using static values. Next you will see in the path that I am using /../td[6]. The '..' means go up the tree to the parent node which would be the table row, then /td[6] tells Ranorex to give us the 6th TD element in that row which happens to be the 'Trace Number'
hope this helps