Find a row in a Ranorex Table

Ask general questions here.
Fsis
Posts: 11
Joined: Wed Jun 12, 2019 8:27 am

Find a row in a Ranorex Table

Post by Fsis » Thu Jul 11, 2019 12:56 pm

Hi all,

I need to find a row of which two cells equal some distinct values. Using a code module I created a Ranorex table.

How can I iterate through that table and choose that row (or any cell of that row, it doesn't matter).

Thanks in advance
Fabio

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

Re: Find a row in a Ranorex Table

Post by odklizec » Thu Jul 11, 2019 1:00 pm

Hi,

Please post the code you already have and if the code should interact with GUI, upload also a Ranorex snapshot (NOT screenshot) of the GUI you would like to process with your code. Thanks.
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

Fsis
Posts: 11
Joined: Wed Jun 12, 2019 8:27 am

Re: Find a row in a Ranorex Table

Post by Fsis » Thu Jul 11, 2019 1:23 pm

Hello,

I just have the following code:

Ranorex.Table cont = repository."something"."somethin"."something";

The code shouldn't interact with the GUI. I just need the index of the row of which two cells match some variables. I'm sorry if my explanation is not quite clear. Unfortunately I cannot upload a snapshot, because the software I work with is a banking software, and therefore it may contain Client Identifying Data.

Thanks

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

Re: Find a row in a Ranorex Table

Post by odklizec » Thu Jul 11, 2019 1:36 pm

I'm afraid, that without snapshot, I can only provide you some general suggestions, like search this forum for table-related posts (there are quite a lot of them) and check also Ranorex codes samples, available here:
https://www.ranorex.com/help/latest/han ... e-examples
There may be not directly the code you are looking for, but you may find some good examples and ideas.

Generally speaking, you will either have to cycle the table rows/cells and read content of every cell and compare it with variable(s) you are looking for. For this, you may find useful Ranorex code samples from above link. Another way could be constructing a good xpath, which may help you to find proper table cell/row. Unfortunately, without seeing, at very least, Ranorex snapshot, it's impossible to tell how you should construct such xpath.

Here is a small example, which returns childindex of table row, containing two cells of given content.

Code: Select all

int rowIndex = tableElement.CreateAdapter<Ranorex.TableTag>(false).FindSingle(elementTR.Path).ChildIndex;
Where table element is a repo element, pointing to tbale of your choice and elementTR, points to repo element, which should contain two cells of expected content.
xpath of given table...
body/div//table
xapth of row containing two cells of given content...
.//td[@innertext='Third element ']/../td[@innertext='blue']/parent::tr
You can test the above code and xpaths with this sample web table:
https://www.ranorex.com/web-testing-examples/
Last edited by odklizec on Thu Jul 11, 2019 2:34 pm, edited 1 time in total.
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

Fsis
Posts: 11
Joined: Wed Jun 12, 2019 8:27 am

Re: Find a row in a Ranorex Table

Post by Fsis » Thu Jul 11, 2019 2:34 pm

odklizec wrote:
Thu Jul 11, 2019 1:36 pm
I'm afraid, that without snapshot, I can only provide you some general suggestions, like search this forum for table-related posts (there are quite a lot of them) and check also Ranorex codes samples, available here:
https://www.ranorex.com/help/latest/han ... e-examples
There may be not directly the code you are looking for, but you may find some good examples and ideas.

Generally speaking, you will either have to cycle the table rows/cells and read content of every cell and compare it with variable(s) you are looking for. For this, you may find useful Ranorex code samples from above link. Another way could be constructing a good xpath, which may help you to find proper table cell/row. Unfortunately, without seeing, at very least, Ranorex snapshot, it's impossible to tell how you should construct such xpath.
Hi,

All I can do is post a screenshot of the snapshot.

Both of the values (red circles) need to match another value. If that is the case, the solution needs to click any of the cells of that row to continue.

Thanks in advance.

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

Re: Find a row in a Ranorex Table

Post by odklizec » Thu Jul 11, 2019 2:37 pm

I'm afraid, screenshot of snapshot is useless. Just check the sample I provided and eventually, search the similar discussions on this forum.
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