I have been trying a simple program that navigates and fetches data from the new page, comes back in history and open other page and fetch data and so on until all the links hav
Please check this code
private void extractText() {
try {
List rows = driver.findElements(By.xpath("//*[@id='gvSearchResults']/tbody/tr"));
List links = null;
System.out.println(rows.size());
for (int i = 0; i < rows.size(); i++) {
links = driver.findElements(By.xpath("//*[@id='gvSearchResults']/tbody/tr/td[1]/a"));
WebElement ele= links.get(0);
System.out.println(ele.getText() + ", ");
ele.click();
System.out.println("After click");
driver.findElement(By.id("ctl00_MainContent_btnBack")).click();
}
} catch (Exception e) {
e.printStackTrace();
}
}