Hope someone can help me. I have the following code and I am getting the Exception thrown: 'OpenQA.Selenium.StaleElementReferenceException'
IList<IWebElement> WeekDays = Chromedriver.FindElements(By.XPath("//td[@class='dxeCalendarDay']"));
foreach (IWebElement Days in WeekDays)
{
string WeekDaysResults = Days.Text;
if(string.IsNullOrEmpty(WeekDaysResults))
{
//Do Nothing
}
else
{
if(WeekDaysResults == FirstDayOfCurrentMonth)
{
Days.Click();
Debug.WriteLine("Week Days: " + WeekDaysResults);
}
}
}
I'm getting the exception on this code string WeekDaysResults = Days.Text;
The error:
OpenQA.Selenium.StaleElementReferenceException: 'stale element reference: element is not attached to the page document
I tried a try catch block but that did not work. Thanks in advance.