title: How to use selenium 2 PageFactory init Elements with Wait.until()?
body: <p>The code snippet below works fine, but I'm having a little trouble with the <code>wait.until()</code> line:</p>
  
  <pre><code>wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']")));
  </code></pre>
  
  <p>It works but I want to send my <code>PageFactory</code> <code>WebElement</code> <code>homePageLink</code> instead:</p>
  
  <pre><code>wait.until(new ElementPresent(homePageLink));
  </code></pre>
  
  <p>Is there any way to do that?</p>
  
  <p>These new fangled Selenium 2 features have got my head in a bit of a spin and I can't find much documentation.</p>
  
  <p>Thanks.</p>
  
  <pre><code>public class GoogleResultsPage extends TestBase {
  
      @FindBy(xpath = "//a[@title='Go to Google Home']")
      @CacheLookup
      private WebElement homePageLink;
  
      public GoogleResultsPage() {  
          wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']")));
          assertThat(driver.getTitle(), containsString("Google Search"));
      }  
  }
  
  public class ElementPresent implements ExpectedCondition&lt;WebElement&gt; {
  
      private final By locator;
  
      public ElementPresent(By locator) {
          this.locator = locator;
      }
  
      public WebElement apply(WebDriver driver) {
          return driver.findElement(locator);
      }
  }
  </code></pre>