I wrote the below method in my Page.class for reusing implicit wait.
public WebDriver waitForElementToLoad(WebElement element)
{
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.presenceOfElementLocated((By) element));
return (driver);
}
In my test.class I am using page factory elements, for example:
//Save button
@FindBy(xpath = "//*[@*='Save']")
private WebElement saveButton;
Now I am trying to call:
waitForElementToLoad(saveButton);
from test.Class but I am getting below error.
"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')"
I also tried
WebElement saveButton = driver.findElement(By.xpath("//*[@*='Save']"));
waitForElementToLoad(saveButton);
but no luck.
How can I make this work?