Find cell based on two column values

Ask general questions here.
karltinsly
Posts: 43
Joined: Tue Jun 07, 2016 9:59 pm

Find cell based on two column values

Post by karltinsly » Mon Oct 11, 2021 3:36 pm

I have a table that looks like this:

Period Year
1 2021
2 2021
3 2021
4 2021
1 2022
2 2022
3 2022
4 2022

I need to be able to select a row based on the combination of those two fields - for example, period 2 of 2022. I've tried a couple of different ways to get there, but I'm not getting the right cell. Here's what I've tried so far:

<table path>/column[@text='Period']/cell[@text='2']/../../column[@text='Year']/cell[@text='2022'] - this gets the first cell in the year column that has 2022 in it - i.e., the 1/2022 row.

<table path>/column[@text='Year']/cell[@text='2022']/../../column[@text='Period']/cell[@text='2'] - this gets the first period cell that has a 2 in it - i.e., the 2/2021 row.

There are other columns in the table. Once I can select the correct row, I can capture the row ID and use it to navigate to the other columns. So far though, I've been unable to create a path that gets me to the right row. I just need to click in one of the cells to select the row.

How can I create a path to click on a cell based on the two columns above?

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

Re: Find cell based on two column values

Post by odklizec » Mon Oct 11, 2021 3:43 pm

Hi,

Please upload a Ranorex snapshot (NOT screenshot) of the the table in question. I think you will most probably have to use column indexes to get the proper cell. But it's hard to tell without seeing the snapshot. 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

karltinsly
Posts: 43
Joined: Tue Jun 07, 2016 9:59 pm

Re: Find cell based on two column values

Post by karltinsly » Mon Oct 11, 2021 4:02 pm

Here's the snapshot. Thanks!

karltinsly
Posts: 43
Joined: Tue Jun 07, 2016 9:59 pm

Re: Find cell based on two column values

Post by karltinsly » Mon Oct 11, 2021 4:08 pm

Hmm. It looks like it didn't upload. I tried again and this time I see a message that says "Failed to move uploaded file."

I tried with a zipped version of the file and got the same thing. Am I missing a step?

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

Re: Find cell based on two column values

Post by odklizec » Mon Oct 11, 2021 4:40 pm

Maybe it's too big even if zipped? Could you please upload it to google drive, one drive or similar file sharing service and here post a link? 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

karltinsly
Posts: 43
Joined: Tue Jun 07, 2016 9:59 pm

Re: Find cell based on two column values

Post by karltinsly » Mon Oct 11, 2021 4:41 pm

Okay, I got rid of ancestors and backed up the tree a little ways and now the file is small enough to attach. Hope there is enough here for you to see what I need to do.
You do not have the required permissions to view the files attached to this post.

karltinsly
Posts: 43
Joined: Tue Jun 07, 2016 9:59 pm

Re: Find cell based on two column values

Post by karltinsly » Mon Oct 11, 2021 10:40 pm

Okay, well I got something that works for my application. In case anyone else is looking for this sort of thing, here's what worked for me.

This will get the cell for the year I'm looking for in the row of the period I'm looking for:
<table path>/row/cell[@text=$varLookupPeriod]/../cell[@text=$varLookupYear]

I click in that cell and use a Get value action to get the rowindex of that cell, then use the row index to find other columns in table. I'm saving the rowindex in $varRowToUpdateIdx

Here are some examples (Description, Total, and Category rows):
<table path>/column[@text='Description']/cell[@rowindex=$varRowToUpdateIdx]
<table path>/column[@text='Total']/cell[@rowindex=$varRowToUpdateIdx]
<table path>/column[@text='Category']/cell[@rowindex=$varRowToUpdateIdx]

Hope this helps someone.