I\'m writing some automated tests for using the selenium chrome driver. I trying to write a reusable method that will explicitly wait for elements to appear and then call th
I wrote an explicit wait for my selenium test in the following manner:
I declared my WebElement to be found with an @FindBy annotation added referencing the Id as follows:
@FindBy(how = How.ID, using = "home")
private WebElement home;
Then my method that waits for an element to load was written as follows:
public WebElement isElementLoaded(WebElement elementToBeLoaded) {
WebDriverWait wait = new WebDriverWait(driver, 15);
WebElement element = wait.until(ExpectedConditions.visibilityOf(elementToBeLoaded));
return element;
}
This allowed me to reference any element I was waiting for by name that I had annotated with a find by, regardless of the @FindBy method used.