I am getting an error as
"stale element reference: element is not attached to the page document", when second time column loop is executed (@line: Columns_row.get(column).click();).
Note: First time column will get clicked and mobile details will get printed on console.
Please find the below sample script:
//To locate rows of table.
List < WebElement > rows_table = driver.findElements(By.xpath("xpath/tr"));
//To calculate no of rows In table.
int rows_count = rows_table.size();
//Loop will execute till the last row of table.
for (int row = 0; row < rows_count-25; row++) {
driver.manage().timeouts().implicitlyWait(5000, TimeUnit.SECONDS);
String li= rows_table.get(row).getAttribute("xxx");
System.out.println(li);
//To locate columns(cells) of that specific row.
List < WebElement > Columns_row = rows_table.get(row).findElements(By.xpath("xpath/td[2]//span/a"));
//To calculate no of columns (cells). In that specific row.
int columns_count = Columns_row.size();
//Loop will execute till the last cell of that specific row.
for (int column = 0; column < columns_count; column++) {
driver.manage().timeouts().implicitlyWait(5000, TimeUnit.SECONDS);
Columns_row.get(column).click();
String mbl = driver.findElement(By.xpath("xpath/a")).getText();
System.out.println(mbl);
driver.findElement(By.xpath("xpath")).click();
}
System.out.println("-------------------------------------------------- ");
}
kindly help if there is any solution for this error.