I used a selenium page object in my project, and also used WebDriverWait to wait until the element is added.
@FindBy(how = How.ID, using = "username")
private WebElement username;
@FindBy(how = How.ID, using = "password")
private WebElement password;
public void login(String username, String password) {
WebDriverWait waiter = new new WebDriverWait(driver, 5, 200);
waiter.until(ExpectedConditions.presenceOfElementLocated(
By.id("username")));
this.username.sendKeys(username)
}
Two questions:
Since we only need:
waiter.until(ExpectedConditions.presenceOfElementLocated( By.id("username"))).sendkey(username);
and not the page object username to return the element you wanted, is the page object pattern useless?
If the page object pattern is necessary, how do I deal with the string "username"? Do I need a new Class for maintaining constants such as:
public final static String USERNAME = "username";
so we can call it on my page?