I'm trying to use only PageFactory in my project, without using fields with type By. And I'm looking to implement something like this:
@FindBy(className = "loading-container")
private WebElement loadingElement;
public LoadingPage(WebDriver driver) {
PageFactory.initElements(driver, this);
this.waitDriver = new WebDriverWait(this.driver, 20);
}
public void waitLoadingToFinish() {
this.waitDriver.until(ExpectedConditions.elementNotExists(loadingElement));
}
Is there a way to implemet custom Expected Condition for this? or any other way to implement this? (without using By fields, only using page factory).
Selenium has this method
For your code
also, you might try to add a javascript executor to wait until the page is loaded
and then your page constructor becomes this