I just cracked my head trying to find how make it work. I am trying to force Selenium
open link
by link
, but it opens on first link again and again, console output shows that loop is working correctly. Tried to use while loop but it doesn`t work too. I am trying to open link after link and change number of the li element to open further link.
for (int footer_links = 1; footer_links < 6; footer_links++) { WebElement self_service_bi = driver.findElement(By.xpath("//div/div/ul/li['$footer_links']/a")); self_service_bi.click(); File srcFile1 = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); File targetFile1 = new File("D:\\DataPineScreenshots\\" + driver.getTitle() + ".png"); FileUtils.copyFile(srcFile1, targetFile1); driver.navigate().back(); System.out.print(footer_links + "\n"); }
exception
?StaleElementReferenceExxception
?