I am trying to select all the divs withclass tile-consultation in (http://raspored.finki.ukim.mk/Home/Consultations), click each of them and extract some data from each div, I tried using:
List<WebElement> professors = driver.findElements(By.className("tile-consultation"));
ListIterator<WebElement> theListOfProfessors = professors.listIterator();
Thread.sleep(1000);
int i = 1;
while(theListOfProfessors.hasNext()) {
WebElement professorI = driver.findElement(By.cssSelector(".tile-consultation:nth-of-type(2)"));
professorI.click();
Thread.sleep(1000);
close = driver.findElement(By.cssSelector("button.btn-close"));
close.click();
Thread.sleep(1000);
}
but how can I change 1 to the 2nd, 3d and so on in a while loop?