title: Code to avoid selenium stale element reference showing error in Eclipse editor
body: <p>I am writing the following code to resolve stale element reference in selenium. However, in eclipse it is giving me error on: final  boolean retrying (By by)-this line.Also, first i wanted to use public boolean retrying(By by) instead of final boolean retrying (By by), but that was giving me error from the eclipse editor.  </p>
  
  <pre><code>package com.TSOne.tcone;
  
  import java.util.List;
  import java.util.concurrent.TimeUnit;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.StaleElementReferenceException;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.openqa.selenium.support.ui.ExpectedConditions;
  import org.openqa.selenium.support.ui.WebDriverWait;
  
  public class CalenderFfdriver {
  
  public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", 
     "/Users/owner/desktop/chromedriver");
  
      WebDriver driver = new ChromeDriver();
      driver.manage().window().maximize();
      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
  
      driver.get("http://www.path2usa.com/travel-companions");
      driver.findElement(By.cssSelector("#travel_date")).click();
  
  
      List&lt;WebElement&gt;dates =driver.findElements(By.cssSelector(".day"));
      System.out.println(dates.size());
  
       final  boolean retrying (By by) {
          boolean result = false;
          int attempts = 0;
          while(attempts &lt; 2) {
              try {
                  driver.findElement(By.xpath("//*[@class='datepicker- 
           switch']")).click();
                  result = true;
                  break;
              } catch(StaleElementReferenceException e) {
              }
              attempts++;
          }
          return;
      }
  
   WebElement navigator =driver.findElement(By.cssSelector(" 
   [class='datepicker-days'] th[class='next']"));
  
      while(!driver.findElement(By.cssSelector("[class='datepicker-days'] 
      th[class='datepicker-switch']")).getText().contains("April")) 
  
          driver.findElement(By.cssSelector("[class='datepicker-days'] 
      th[class='next']")).click();
  
  
  
      for(int i=0;i&lt;dates.size();i++) {
           String text=dates.get(i).getText();
          if(text.equalsIgnoreCase("23"))
  
              dates.get(i).click();
  
      }
  }
  </code></pre>
  
  <p>}</p>