I am trying to get a specific list of webelements from a websites. All of these elements have the exact same xpath, except one number of course. When I am trying to extract all of these elements with the following code, it works perfectly, unless the list contains more than 99 items. If the number in the xpath is above 99, Selenium will just not locate the element at, even though (I have tested it) the xpath stays the exact same.
I have already tried to single out the items, but Selenium acts like the 100th item and all above just do not exist.
I have singled out the following code (simplefied):
String xpath="/html/body/div[1]/div/div[4]/div[2]/div[1]/div/div/div/div/section/div/div/div[2]/section/ol/div[%d]/div/li/div[2]/div/div[1]";
private void getTextFromElements(WebDriver driver){
for(int i=0; i<200; i++){
if(driver.findElements(By.xpath(String.format(xpath, i)).size()!=0){
System.out.println(driver.findElement(By.xpath(String.format(xpath, i))).getText());
}else{
break;
}
}
}
While it prints out the first 99 items perfectly, it throws the exception, that Selenium cannot locate the element as soon as it reaches the 100th element.
This is an example URL, from which I try to extract the data: link.