Boa Tarde mestre, continua com erra deve ser algo que estou fazendo de errado, alguma coisa relacionado a pagina que estou testando, segue as classes que criei:
Classe de teste:
package selenium;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
@SuppressWarnings("deprecation")
public class testeCadastro {
private PaginaCadastro paginaCadastro;
@Before
public void beforeEach() {
this.paginaCadastro = new PaginaCadastro();
}
@After
public void afterEach() {
this.paginaCadastro.fechar();
}
@Test
public void efetuaCadastro() {
paginaCadastro.preencheFormularioDeCadastro("Nome", "Sobrenome", "a@b.com", "senha", "senha", "000.000.000-00",
"Feminino", "10/10/2020", "99999999999", "Brasil", "06233030", "123");
paginaCadastro.finalizarCadastro();
Assert.assertTrue(paginaCadastro.isPaginaDeCadastro());
Assert.assertEquals(true, paginaCadastro.getErro());
}
}
Classe do Selenium:
package selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class PaginaCadastro {
private static final String URL_TESTE = "https://login.saraiva.com.br/registro.html?clientId=authorization_code&redirect_uri=https://vtexid.vtex.com.br/VtexIdAuthSiteKnockout/ReceiveAuthorizationCode.ashx&state=eyJhbGciOiJFUzI1NiIsImtpZCI6IkJDRDMyRkIwNjQ1Q0FENUQzNzdBNUMzMUEwNjBCMDcxMTcxRENGNDIiLCJ0eXAiOiJqd3QifQ.eyJzdWIiOiIxNTIwRkE3NDIxQzU5MThERjcxRkI2QUE5NjZERDk2QkY5OTg3MzAwRjFBRUIwRUQwOEVDNzFDMTAyNUVCOUUzIiwiaXNzIjoidG9rZW4tZW1pdHRlciIsImV4cCI6MTYxMDM3NjI5NSwicHJvdmlkZXIiOiJDbGllbnRlIFNhcmFpdmEiLCJpYXQiOjE2MTAzNzU2OTUsImp0aSI6IjdhMjdkZDgwLWViMzEtNDI1Yi04OTBiLTc4N2QyODYwM2E5OCJ9.MG_53W6M4QLKocUlZGvxLMaljikgp4oG64fElb116gkuubRn6ghUu-UWjqQh-xaaHwfBmqEs1TOyQzytaM_5-Q";
private WebDriver browser;
public PaginaCadastro() {
System.setProperty("webdriver.chrome.driver", "driver/chromedriver.exe");
this.browser = new ChromeDriver();
this.browser.navigate().to(URL_TESTE);
}
public void fechar() {
browser.close();
}
public WebDriver getBrowser() {
return browser;
}
public void setBrowser(WebDriver browser) {
this.browser = browser;
}
public static String getUrlTeste() {
return URL_TESTE;
}
public void preencheFormularioDeCadastro(String nome, String sobreNome, String email, String senha,
String confirmaSenha, String cpf, String sexo, String dataNascimento, String celular, String pais,
String cep, String numero) {
browser.findElement(By.id("InputNome1")).sendKeys(nome);
browser.findElement(By.id("InputSobrenome1")).sendKeys(sobreNome);
;
browser.findElement(By.id("InputEmail1")).sendKeys(email);
browser.findElement(By.id("InputSenha1")).sendKeys(senha);
browser.findElement(By.id("InputConfirmeSenha1")).sendKeys(confirmaSenha);
browser.findElement(By.id("InputCpf1")).sendKeys(cpf);
selecionaSexo(sexo);
browser.findElement(By.id("InputDataNascimento1")).sendKeys(dataNascimento);
browser.findElement(By.id("InputCelular1")).sendKeys(celular);
browser.findElement(By.id("SelectPais1")).sendKeys(pais);
browser.findElement(By.id("InputCep1")).sendKeys(cep);
submeterCep();
browser.findElement(By.id("InputNumero1")).sendKeys(numero);
}
public void selecionaSexo(String sexo) {
WebDriverWait wait = new WebDriverWait(browser, 10);
if (sexo.equals("Masculino")) {
WebElement radio = browser.findElement(By.id("RadioMasculino1"));
wait.until(ExpectedConditions.elementToBeClickable(radio));
radio.click();
} else {
WebElement radio = browser.findElement(By.id("RadioFeminino1"));
wait.until(ExpectedConditions.elementToBeClickable(radio));
radio.click();
}
}
public void submeterCep() {
browser.findElement(By.id("InputCep1")).submit();
}
public void finalizarCadastro() {
browser.findElement(By.id("FinalizarCadastro1")).click();
}
public boolean isPaginaDeCadastro() {
return browser.getCurrentUrl().equals(URL_TESTE);
}
public Object getErro() {
return browser.getPageSource().contains("Informe uma senha");
}
}
Obrigado pela ajuda novamente