I save site links with the following code, But in some sites, I encounter the following error
OpenQA.Selenium.StaleElementReferenceException: 'stale element reference: element is not attached to the page document
(Session info: chrome=xx.x.xxx.xx)
This is my code:
private string followlinks(string url)
{
IWebDriver driver = new ChromeDriver(@"C:\");
driver.Navigate().GoToUrl(url);
//...
//...
//...
foreach (var item in driver.FindElements(By.TagName("a")))
{
var url2 = item.GetAttribute("href");
//...
}
}