I am having an issue removing elements of a list while iterating through the list. Code:
For (WebElement element: list){
    if (!element.isEnabled() || !element.isSelected()){
        list.remove(element);
    }
}
I get a ConcurrentModificationException, which I totally understand. I am removing an item from a list while in the loop that goes through the list. Intuitively, that would screw up the indexing of the loop.
My question is, how else should I remove elements that are either not enabled or selected from this list?
 
     
     
     
     
     
    