Replies: 1 comment 1 reply
-
Hi @DamianSzp, All the page objects inherit the AbstractPageObject class, so all the elements in each object will have this verification, creating an "automatic way to wait for elements". This will make your code cleaner. If you need to manage any additional explicitly wait, I would create its instance in the Inner wait for me is the waiting usage inside a page object method. Example in the public class AbstractPageObject {
protected WebDriverWait wait;
protected AbstractPageObject() {
initElements(new AjaxElementLocatorFactory(DriverManager.getDriver(), configuration().timeout()), this);
wait = new WebDriverWait(DriverManager.getDriver(), Duration.ofSeconds(configuration().timeout()));
}
} Examples of waiting (fake, just as an example // code ignored
// inner
public void fillForm() {
wait.until(ExpectedConditions.elementToBeSelected(By.id("id")));
name.fill("something");
// more code
}
// external
public void waitUntilMessageIsDisplayed() {
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("message")));
}
|
Beta Was this translation helpful? Give feedback.
-
Hi @eliasnogueira
Could you share some examples of how the explicit wait can be implemented or some thoughts what is the best way to do it to keep code clean?
Beta Was this translation helpful? Give feedback.
All reactions