Stale Element Reference Exception | Selenium Forum
M
Posted on 29/09/2016
Hi

I am facing the issue of stale element reference exception in my code and I am stuck over there .Please help me out

I have written the code for extracting the day, month and year in tree they are working but after extracting and clicking the year field , Stale element reference exception is thrown.

String data3= "1992";
driver.findElement(By.xpath("//*[@id='select2-persondtldobyear-container']")).click();
List<WebElement> year=driver.findElements(By.xpath("//li[@role='treeitem']"));
System.out.println(year.size());
for(int i =1;i<year.size();i++)
{
String y=year.get(i).getText();
if(y.equals(data3))
year.get(i).click();
}

M
Replied on 30/09/2016

http://stackoverflow.com/questions/12967541/how-to-avoid-staleelementreferenceexception-in-selenium

http://stackoverflow.com/questions/16166261/selenium-webdriver-how-to-resolve-stale-element-reference-exception