Currently, my code looks like this:
for(int k=1; k<4; k++){
String elem1 = driver.findElement(By.xpath("/html/body/div[4]/div/div/div[2]/div/div/div/div[3]/div[2]/div[2]/div[2]/ul[1]/li[6]/div/ul/li/div/a[k]" + k)).getAttribute("innerHTML");
//String elem2 = driver.findElement(By.xpath("/html/body/div[4]/div/div/div[2]/div/div/div/div[3]/div[2]/div[2]/div[2]/ul[1]/li[6]/div/ul/li/div/a[2]")).getAttribute("innerHTML");
//String elem3 = driver.findElement(By.xpath("/html/body/div[4]/div/div/div[2]/div/div/div/div[3]/div[2]/div[2]/div[2]/ul[1]/li[6]/div/ul/li/div/a[3]")).getAttribute("innerHTML");
System.out.println(elem1);
//System.out.println(elem2);
//System.out.println(elem3);
Thread.sleep(3000);
double value = Double.parseDouble(elem1);
System.out.println(value);
}
As you can see in the String elem1 line, I try to pass the value k into XPath, but it doesn't work. How can I do that? I need to increase the value of k because as you can see in the commented lines it goes: 1-2-3-4...-78...