essa é a classe LoginPage
package br.com.alura.leilao.login;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class LoginPage {
private static final String LOGIN = "http://localhost:8080/login";
private WebDriver browser;
public LoginPage(){
System.setProperty("webdriver.chrome.driver", "drivers/chromedriver.exe");
this.browser = new ChromeDriver();
this.browser.navigate().to(LOGIN);
}
public void fechar() {
this.browser.quit();
}
public void preencheFormDeLogin(String username, String password) {
browser.findElement(By.id("username")).sendKeys(username);
browser.findElement(By.id("password")).sendKeys(password);
}
public void EnviarLogin() {
browser.findElement(By.id("login-form")).submit();
}
public boolean isPaginaDeLogin() {
return browser.getCurrentUrl().equals(LOGIN);
}
public Object getNomeUserLogado() {
try{
return browser.findElement(By.id("usuario-logado")).getText();
}catch (NoSuchElementException e){
return null;
}
}
public void navegaParaPaginaDeLances() {
this.browser.navigate().to("http://localhost:8080/leiloes/2");
}
public boolean contemTxt(String texto) {
return browser.getPageSource().contains(texto);
}
public boolean isPaginaDeLoginComDadosInvalidos() {
return browser.getCurrentUrl().equals(LOGIN + "?error");
}
}