Click each row in table

Class library usage, coding and language questions.
davilo61
Posts: 8
Joined: Wed May 28, 2014 2:46 pm

Click each row in table

Post by davilo61 » Fri May 30, 2014 7:36 pm

Hi, I'm new to coding and ranorex and I am trying to develop automation for the following workflow:
This is the basic outline of the flow:

1. Select row 1 in a table
2. Set address (based on selection in step 1)
3. Process Order

4. Select row 2 from same table
...

I tried using the invoke action and set value with a data source, but was unable to understand how to proceed. I also am looking at using a 'for each' loop. Would the 'for each' loop need to include steps 2 and 3? I would think so ,but wondered what is the best practice for that flow. Is there a simpler solution using a datasource and mouse click ?

Thanks in advance for any help. Much appreciated!!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Click each row in table

Post by Support Team » Mon Jun 02, 2014 1:32 pm

Hi,

From what you wrote I would say that the data-driven approach would work for you.
You can for instance use a test case with a data connection which holds the values which should be used to set the address in the specific row.
In order to make it data driven you need to add the Set Value action to the recording of the specific test case. As Value of the Set Value action you can use a variable which can be bound to your data connector and as the repository item you need to use an item with a RxPath which uses a variable in order to address the different rows, so instead of a hard coded row number you need to use a repository variable instead. This repository variable will then be automatically copied to the specific recording in order to make it bindable.

I created a small sample with a Key Sequence instead of a Set Value action but the rest should be the same:
Step 1: Make the Set Value in my case the Key Sequence action data driven:
SetVariable.png
Step 2: Make the RxPath to the address element in my case to the cell data driven, instead of the row-index use a variable:
RepoItem.png
Step 3: Now you should see two variables in the VARIABLES... window of your recording:
Variables.png
Step 4: Now you need to bind the variables to the data source, the data source can look like:
DataSource.png
and the binding like:
Binding.png
Additionally I uploaded the small sample solution.
In order to run it you need to first open Microsoft Excel.

For more information please see the following links: Lesson 3: Data-Driven Testing and Set Value.

Regards,
Markus
You do not have the required permissions to view the files attached to this post.

davilo61
Posts: 8
Joined: Wed May 28, 2014 2:46 pm

Re: Click each row in table

Post by davilo61 » Mon Jun 02, 2014 3:17 pm

Thanks for the reply. First, let me state that I was not clear on the steps I outlined and what I need is simpler than your solution. I saved and will certainly use your example as a basis for writing to cells in the future. I really needed to be able to automate the following:
1. Click in row (select row) where rowindex is 1
Process
2. Click in row where rowindex is 2
Process
...

Basically. click in row where rowindex = datasource row

I'm stuck on the 'where' as I don't want to change the value, but simply want to select the row .

Thanks for your help.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Click each row in table

Post by Support Team » Wed Jun 04, 2014 2:05 pm

Hi,

What value do you not like to change, the rowindex or the values for the address?

I am afraid I did not entirely understand the question. May I ask you to describe the issue in detail?

Thanks,
Markus

davilo61
Posts: 8
Joined: Wed May 28, 2014 2:46 pm

Re: Click each row in table

Post by davilo61 » Wed Jun 04, 2014 2:23 pm

Hi, I actually do not want to change a value, but rather to automate the action of clicking (iterating) through each row in the table.

Ex.
Table 1 contains 50 rows

Automation desired:
1. Click row 1
Save
2. Click row 2
Save

I am thinking I'll need a loop.

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: Click each row in table

Post by mzperix » Wed Jun 04, 2014 4:48 pm

Hi davilo61,

in Ranorex studio, the loop functionaitly can be achieved by using datasource. The way Ranorex support showed is the way to go IF you are using Ranorex Studio. There is no easier way to click on a row of a table, you HAVE to use avariable in repository, and you HAVE to use a dataconnector to make a loop.
Again this is in Ranorex Studio. If you are coding, less hassle is needed. You can create a code module that takes care of everything.

The solution provided to you can be easily adopted to your case:
1. Use only the RowVariable column of the dataconnector
2. Replace the Key sequence action with your Save action(s)
3. Put the RowVariable variable into the repository
4. Bind the variables of the repository and data connector variable
5. Run
6. ????
7. Profit :)

Best Regards,
Zoltan