title: Passing WebElement as parameter to implicit wait method
body: <p>I wrote the below method in my Page.class for reusing implicit wait.</p>
  
  <pre><code>public WebDriver waitForElementToLoad(WebElement element)
  {
          WebDriverWait wait = new WebDriverWait(driver, 60);
          wait.until(ExpectedConditions.presenceOfElementLocated((By) element));
          return (driver);
  }
  </code></pre>
  
  <p>In my test.class I am using page factory elements, for example:</p>
  
  <pre><code>//Save button
  @FindBy(xpath = "//*[@*='Save']")
  private WebElement saveButton;
  </code></pre>
  
  <p>Now I am trying to call:
  <code>waitForElementToLoad(saveButton);</code> 
  from test.Class but I am getting below error.</p>
  
  <blockquote>
    <p>"java.lang.ClassCastException: class com.sun.proxy.$Proxy12 cannot be
    cast to class org.openqa.selenium.By (com.sun.proxy.$Proxy12 and
    org.openqa.selenium.By are in unnamed module of loader 'app')"</p>
  </blockquote>
  
  <p>I also tried </p>
  
  <pre><code>WebElement saveButton = driver.findElement(By.xpath("//*[@*='Save']"));
  waitForElementToLoad(saveButton);
  </code></pre>
  
  <p>but no luck.</p>
  
  <p>How can I make this work?</p>