I have a list of elements which I have to scan using the iterator, and click on the desired element.
List <WebElement> lt = driver.findElements(By.tagName("strong"));
  Iterator <WebElement> it= lt.iterator();
  while(it.hasNext())
  {
   if(it.next().getText().equals(cat))
   {
    it.next().click();
    break;
   }
  }In my code, when the iterator finds the element, the execution goes inside the if loop, but selects the next element, when it encounters it.next().click();
how do I click on the current element that has been pointed by the if loop?
 
     
    