1
Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
if(elements.size()>0) 
{
 for(WebElement str: elements) 
  {

FirstLink.click();

wait = new WebDriverWait(driver,30);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

//Second link 

driver.findElement(By.partialLinkText("employees on LinkedIn")).click();
Thread.sleep(3000);

//Going to 2 screens back
((JavascriptExecutor) driver).executeScript("window.history.go(-2)");
 }
} 
Hakan Dilek
  • 2,178
  • 2
  • 23
  • 35

1 Answers1

0

Stale element exception means element is there on page but selenium driver could not interect with that element ,there are 2 ways to resolve this stale element exception

1.Refresh() use this method

2.By using for loop click

Justin Lambert
  • 940
  • 1
  • 7
  • 13