Reputation: 63
I have application in which I need to approve webelement from the list there's total 50 item in the list Steps-
Now problem is when I approve the element it get removed from list, and now my for loop skips the next element i;e 2 element from list , jumps to third element and approves it
in this scenario only 25 elements are getting approved rest remain in pending status
Any logic help would appreciate
Thanks, Ravi
Upvotes: 0
Views: 60
Reputation: 3026
Without seeing your code, I'm going to assume that you are looping over the list and incrementing by one every time you go through the loop. And since the first element is removed from the list after approval, the second element becomes the first element. And because your loop increments by one, it goes to the second element in the list.
My suggestion would be to use a while {} instead of a for loop, which will select and approve the first element in the list while the size of the list is >= 1. That way you should get them all.
In pseudocode:
while (element.size >= 1) {
// approve element at first index
}
Upvotes: 1