Is there a way to make the code below simpler and shorter?
boolean clicked = false;
for (WebElement anchor : anchorLinksForProducts) {
if (anchor.getAttribute("href").contains(id)) {
anchor.click();
clicked = true;
break;
}
}
Assert.assertTrue(clicked, "Could not find a valid product link with id : " + id);