title: Is there a cleaner way to write this polling loop?
body: <p>I am writing automated test cases in Selenium/WebDriver in java.  I have the following code implemented to poll for existing WebElements, but as I am not an expert in Java I was wondering if there is a cleaner way to write this method:</p>
  
  <pre><code>/** selects Business index type from add split button */
      protected void selectBusinessLink() throws Exception
      {
          Calendar rightNow = Calendar.getInstance();
          Calendar stopPolling = rightNow;
          stopPolling.add(Calendar.SECOND, 30);
          WebElement businessLink = null;
          while (!Calendar.getInstance().after(stopPolling))
          {
              try
              {
                  businessLink = findElementByLinkText("Business");
                  businessLink.click();
                  break;
              }
              catch (StaleElementReferenceException e)
              {
                  Thread.sleep(100);
              }
              catch (NoSuchElementException e)
              {
                  Thread.sleep(100);
              }
              catch (ElementNotVisibleException e)
              {
                  Thread.sleep(100);
              }
          }
          if (businessLink == null)
          {
              throw new SystemException("Could not find Business Link");
          }
      }
  </code></pre>
  
  <p>This particular line is what makes me think the code is a little dirty:</p>
  
  <pre><code> while (!Calendar.getInstance().after(stopPolling))
  </code></pre>