Skip to content

Instantly share code, notes, and snippets.

@eliasnogueira
Last active August 21, 2022 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliasnogueira/aa472b39189db0cb421a0c8916033278 to your computer and use it in GitHub Desktop.
Save eliasnogueira/aa472b39189db0cb421a0c8916033278 to your computer and use it in GitHub Desktop.
Simple Page Objects example waiting for an element in the constructor
public class PageObjectExample {
private WebDriver driver;
@FindBy(id = "email")
private WebElement email;
@FindBy(id = "password")
private WebElement password;
@FindBy(name = "next")
private WebElement next;
public PageObjectExample(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
new WebDriverWait(driver, Duration.of(5, ChronoUnit.SECONDS))
.until(ExpectedConditions.visibilityOf(email));
}
public void login(String email, String password) {
this.email.sendKeys(email);
this.password.sendKeys(password);
next.click();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment