title: Loop while a control exists
body: <p>Searched all over trying to find an answer to this.</p>
  
  <p>I want to enter data on a web page. I enter the loop and enter the data. I then click the Next button. This continues until there are no more users. Once there are no more users the page changes and there is no more Next button to click.</p>
  
  <p>I'm not sure how to code this in Java with Selenium. C#, no sweat. Any ideas?</p>
  
  <p>This works once then the reference goes stale the next time through the loop.</p>
  
  <pre><code> WebElement loopCondition = driver.findElement(By.name("imgnext"));
   while (loopCondition.isEnabled()) {
        myElement = (new WebDriverWait(driver, 30))
             .until(ExpectedConditions.elementToBeClickable(By.id("originalSalaryAmt")));
        myElement.sendKeys("1000");
        myElement.sendKeys(Keys.RETURN);
        myElement = (new WebDriverWait(driver, 30))
             .until(ExpectedConditions.elementToBeClickable(By.name("imgnext")));
        myElement.click();
  </code></pre>
  
  <p>}</p>
  
  <p>There is no .exists in Java like there is in C# so I'm not sure how to deal with this situation. I just want to enter data and click Next to go to the next user until the next button no longer exists.</p>