Page 1 of 1

accessing a repository item using a counting variable

Posted: Mon Jun 26, 2017 11:47 am
by prostennik
Hi,

I have a grid input control with up to 80 lines. I need to dynamically change the line I am accessing according to the amount of items that have been entered already, these item counts differ depending on runtime variables so they may end up on different Rows dependent upon runtime:

Row1_Input
Row2_input
...
Row80_Input

I have a variable counting the amount of items already entered , what I want is to enter Row_Input so the next item is automatically entered on the correct line. Ghost code would be something like:

for i in rows:
repo.grid.Row_Input.PressKeys("Item");

Am I thinking completely incorrectly here? Anyone tell me where I am going wrong please?

Re: accessing a repository item using a counting variable

Posted: Mon Jun 26, 2017 2:19 pm
by RobinHood42
Hi,

it would be great if you could provide more information. A Ranorex snapshot file would allow us to better understand your application under test.

Snapshot file: https://www.ranorex.com/support/user-gu ... pshot.html
I have a variable counting the amount of items already entered , what I want is to enter Row_Input so the next item is automatically entered on the correct line. Ghost code would be something like:

So, basically, you just want to get the first row, which doens't have any input value, correct?

Cheers,
Robin 8)

Re: accessing a repository item using a counting variable

Posted: Mon Jun 26, 2017 3:02 pm
by Vaughan.Douglas
Something along these lines might work best. We could provide a more accurate sample if we had a snapshot so we knew what types we were dealing with.
foreach (var myRow in myRepo.Root.TableWithRow.FindDescendants<Ranorex.Row>())
            {
                myRow.FindSingle<Ranorex.Unknown>("RxPath").PressKeys("Item");
            }

Re: accessing a repository item using a counting variable

Posted: Tue Jun 27, 2017 6:48 am
by prostennik
Hi,

snapshot attached. And yes, basically I just want to write an item in the next row with no current value written.
I was looking at findsingle and assumed I would land there, but I was not able up to now to get it working. :shock:

Thanks

Re: accessing a repository item using a counting variable

Posted: Tue Jun 27, 2017 9:12 am
by RobinHood42
Hi,

Thank you for uploading the snapshot file.

Maybe the following code snippet helps you.
Table sapTable = "/form[@connectiondescription='QCA [SPACE]']//table[@name='SAPMV45ATCTRL_U_ERF_ANGEBOT']";

            foreach (var row in sapTable.FindChildren<Row>())
            {
                foreach (var cell in row.FindChildren<Cell>())
                {
                    if (String.IsNullOrEmpty(cell.Text))
                    {
                        //Do anything
                        cell.Click();
                    }
                }
            }
The code finds all cells within your table, which do not have a text.

Cheers,
Robin 8)

Re: accessing a repository item using a counting variable

Posted: Tue Jun 27, 2017 12:08 pm
by prostennik
works perfectly :mrgreen:

Many thanks Robin. I was going the right way, but I am not sure I would have arrived :)