I'm trying to get some data from a JSP page, the page has a table with pagination and i'm trying to get the values from each table page.
As i could see each element is created dynamically with a class and name set by the server with timestamp and other stuff so i have to use more generic data as possible on DOMs to get them.
Once the first page is clicked the page generate a second paginator which will be the real one..
The issue is that after i processed 3 pages from the paginator i get the following error:
'stale element reference: element is not attached to the page document (Session info: chrome=89.0.4389.114)'
But actually the DOM element exists on the page but it's recreated with other name and class but it should be get anyway...
Here is my code:
var pages = searchResult.FindElements(By.ClassName("custom-pagination"));
foreach (var page in pages[0].FindElements(By.TagName("input")))
{
var PageValue = page.GetAttribute("value");
if (PageValue == "<<") continue;
if (PageValue == ">") break;
if (PageValue != "1")
{
page.Click();
WaitUntilElementNotVisible(SelectorByAttributeValue("iawaitpanel", "true"), 30000, driver);
}
foreach (var azienda in driver.FindElements(By.ClassName("item_list")))
{
DataRow row = table.NewRow();
row["REGIONE"] = NomiRegioni[IndexRegione];
row["NOME AZIENDA"] = azienda.FindElement(By.ClassName("txtGreen")).Text;
var indirizzo = azienda.FindElement(By.ClassName("sede")).Text.Replace("Sede Legale", "").Trim();
row["INDIRIZZO"] = indirizzo;
row["CAP"] = indirizzo;
row["CITTA"] = indirizzo;
row["MAPS"] = azienda.FindElement(SelectorByAttributeValue("title", "Vai a Google Maps")).GetAttribute("href");
table.Rows.Add(row);
}
}
And here is a small fiddle of how the page looks like..
I've yed read this question and i've yet tried to set like in CATCH
the code again where i get the element but it has no effect...