Problem reading links with selenium in C# RRS feed

  • Question

  • 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:\");


    //... //... //... foreach (var item in driver.FindElements(By.TagName("a")))             {                                var url2 = item.GetAttribute("href");         //...          }


    • Edited by parvizb Wednesday, July 22, 2020 8:15 PM
    • Moved by KareninstructorMVP Wednesday, July 22, 2020 8:42 PM moved from C# forum
    Wednesday, July 22, 2020 8:11 PM

All replies

  • Hello,

    Use the following forum


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    • Marked as answer by parvizb Wednesday, July 22, 2020 8:26 PM
    • Unmarked as answer by parvizb Wednesday, July 22, 2020 8:34 PM
    Wednesday, July 22, 2020 8:16 PM