title: Selenium Webdriver with Java: Element not found in the cache - perhaps the page has changed since it was looked up
body: <p>I am initializing a variable in the beginning of my class:</p>
  
  <pre><code>public WebElement logout;
  </code></pre>
  
  <p>Later on in the code, in some method, the first time I encounter the logout button, I assign a value to that variable (in the brackets of an if/else statement):</p>
  
  <pre><code>logout = driver.findElement(By.linkText("Logout"));
  logout.click();
  </code></pre>
  
  <p>I then use "logout" once more, successfully, at another stage of my test:</p>
  
  <pre><code>logout.click();
  </code></pre>
  
  <p>And at the end of the test, at a place where the element is the same (By.linkText ("Logout")), I get this error:</p>
  
  <pre><code>Element not found in the cache - perhaps the page has changed since it was looked up
  </code></pre>
  
  <p>Why?</p>
  
  <p>EDIT: Actually, I dont successfully use the logout.click(); commant at another stage of my test. Looks like I cant use it again. I have to create a logout1 webelement and use it...</p>