Suggest an adequate way to loop each item search and click on it. (Why do you need this, please do not ask. In this case, this is the only way) With goto, everything would be beautiful, but alas .. Displaying each search for an element into a separate method is also not beautiful. I have a couple of dozen of such elements, and if each of them is wrapped with code for a method, then everything looks bad.
public static void findElement() { WebElement element = driver.findElement(By.id("")); element.click(); WebElement element1 = driver.findElement(By.cssSelector("label"); element1.click(); WebElement element2 = driver.findElement(By.id("")); element2.sendKeys(elementsOfTheApplication.getC()); try { goto: WebElement element3 = driver.findElement(By.cssSelector("s']")); element3.click(); } catch (Exception e) { //переход на goto e.printStackTrace(); } WebElement element4 = driver.findElement(By.cssSelector("]")); element4.click(); WebElement element5 = driver.findElement(By.cssSelector("l-']")); element5.click(); }