Posted: 27 Oct 2016 15:36 EDT Last activity: 6 Nov 2018 20:02 EST
Unable to loop through a Grid - Openspan
I want to click each and every row of java table grid and perform some operation. I was able to get the total rowCount of the Grid as well but the "For Loop" is not working and facing the below issues. Can you please help!
1. Am unable to set the grid Rowcount to ForLoop Limit(Currently I have hardcoded to 1000)
2. The ForLoop is not iterating.
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
The RowCount property is a data property that supplies how many rows are in the grid. You should use the RowCount property to set the limit of the for loop.
Instead of connecting the RowCount to the Startloop of the forloop1 using execution output (the yellow dot to the right of the design block), you should connect the data output (blue dot right to the design block) to the limit input of the for loop. You will likely need to right click the limit: 1000 section of the for loop and select reset in the context menu that pops up so that the data input (The last blue dot at the bottom of the for loop) enables for the RowCount output connection to be made to the Limit input.
You will then need to change the ClickCell block to connect from the Yielded output of the for loop (the second yellow dot of the forloop1 that is off to the right) instead of the Startloop output of the forloop. Whenever the forloop1 detects that there is another iteration to be made, it will execute the automation logic out of the yield.
Lastly, instead of using the Increment data output (second to last blue dot on the right side of the forloop1 block), you will need to use the Index data ouput (first blue dot to the right side of the forloop1 design block) to the row parameter. The index will change with each iteration allowing you to increase each row per iteation. The Increment only tells you how much of an increment occurred with each iteration. The index lets you know which index of the loop you are currently on.
Below is a help link that explains in detail about how the forloop parameters look. Please have a look for future references.
To dynamically set the Limit on a ForLoop, right click on Limit and choose Reset Changes.
You can now hook up your grid.rowcount to the limit. Next, all execution from the ForLoop comes from the Yielded dot. So do something like this.
When you want to break out of your loop, use the Break Method of the ForLoop.
When the loop is complete the execution will continue from the Completed dot. If you break, the execution will continue from the Break dot. Make sure your execution lines cover both scenarios if your ForLoop is going to break. The execution from both dots could go to the same place as well, but remember that Break and Completed must both be covered.