title: Test if element is present using Selenium WebDriver?
body: <p>Is there a way how to test if an element is present? Any findElement method would end in an exception, but that is not what I want, because it can be that an element is not present and that is okay, that is not a fail of the test, so an exception can not be the solution.</p>
  
  <p>I've found this post: <a href="https://stackoverflow.com/questions/6992993/selenium-c-sharp-webdriver-wait-until-element-is-present">Selenium c# Webdriver: Wait Until Element is Present</a>
  But this is for C# and I am not very good at it. Can anyone translate the code into Java? I am sorry guys, I tried it out in Eclipse but I don't get it right into Java code.</p>
  
  <p>This is the code:</p>
  
  <pre><code>public static class WebDriverExtensions{
      public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds){
  
          if (timeoutInSeconds &gt; 0){
              var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
              return wait.Until(drv =&gt; drv.FindElement(by));
          }
  
          return driver.FindElement(by);
      }
  }
  </code></pre>