I have to click on the first twenty rows of the data table which has more than twenty rows existing… sometimes the number of rows is less than twenty and on that occasion, I have to click on the existing rows . What condition should I give to achieve that?
Can you try the following expression then iterate all the row of result datatable?
newDt = originalDt.AsEnumerable.Take(20).CopyToDataTable
If number of rows of originalDt is larger than 20, number of rows of newDt is 20.
If number of rows of originalDt is less than 20, number of rows of newDt is same as originalDt.
Or if you want to use less code expresions and more of the native building blocks:
Go for the regular for each row in DT:
This will loop from 0 to the number of rows.
Then set the max iterations flag to 20:
So it will not exceed the desired 20 clicks as per your requirement. The for each loop will assure there is no click more than there are rows in your datatable.
Saves you messing around with expressions you or your team might not be familiar with.
When you say Data Table is that the table on the screen ?
Hello @Althaf_nazeer_Nazeer ,
From your query what I understood is you have a table and you need to click on the first 20 items if existing and if its less it need to dynamically click only on the available items.,
Hope you are using some webpage or application for this process instead of an excel. If it for a webpage/app what you can do is.
1)Use a while loop (i<=20)
2)Use element exists activity on the First element. If its try\false you will get a boolean out.
3) if True, use a click activity and click on that element, if false use a break activity.
Here in the 2nd Step Element exists and click activity should be dynamic. So you need to pass the value of “i” inside the selector. If you check the selector there should be some value like idx or similar which you can make dynamic by passing “i”.
Thanks for your reply