Why is "For Each Row" skipping rows of an extracted data table

I used screen scraping to grab an online data table.

Now, I’d like to use a FOR EACH ROW loop to go through and click the “PDF” checkboxes on the right hand side of this image:

Every PDF box need to be checked, one at a time.

To do this, I used a CLICK activity with the webctrl id in the selector set to a integer variable called “rownumber”. rownumber starts at 0, but, it is increased by +1 each iteration of the loop.

The loop looks like this:

rownumber = 0

ForEach Row in ExtractDataTable

CLICK selector webctrl id=‘cb{{rownumber}}’

rownumber = rownumber+1

When I run this script, only some PDF checkboxes are selected. And, it seems random. Sometimes boxes 1, 2 and 5 are clicked, other times, boxes 3, 5, and 9 will be checked. There’s seems to be no order.

Is there anything obvious that I might be doing wrong here (I’m pretty much a complete novice with this…)

Thanks!

The “for each row” activity already automatically loops through each row inside of a data table, so having a variable that increases as a count could cause weird errors. if you want to access a certain part of a row in each loop you can use the following syntax:

Capture

Just replace the 2 with your column number.

This way for each row it will use the data from that specific row.

If you need anymore clarification feel free to ask!

Thanks!

So, using the screenshot example, the checkboxes are in Column 2 of the table I created from that. How would I use your suggestion in conjunction with CLICK?

Something like:

ForEach row in dataTable

CLICK <webctrl id=‘row(2)’

??

Hmm I may have misunderstood your question in my haste. In extract datatable, I assume you are extracting the table in the picture. Now that i’m looking back at your original question it seems like that logic should be working. I would double check the output of your data table to make sure that it is including all the rows, also I would try using running in debug mode with slow step enabled and see if there is any reason it is skipping them. Sorry for my confusion.

Thanks, yes, my bad. Sorry. Turns out I had the variable being incremented inside of a separate For Each loop (the WRONG one). I put the ASSIGN activity in the right place and now everything is groovy.

Thanks!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.