Ao rodar o teste do cap3 esta sendo apresentado uma exception: Alguém já passou por essa situação?
package br.com.caelum.teste;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class UsuariosPage {
private WebDriver driver;
public UsuariosPage(WebDriver driver) {
this.driver = driver;
}
public void visita() {
driver.get("http://localhost:8080/usuarios");
}
public NovoUsuarioPage novo() {
driver.findElement(By.linkText("Novo Usuário")).click();
return new NovoUsuarioPage(driver);
}
public boolean existeNaListagem(String nome, String email) {
return driver.getPageSource().contains(nome) && driver.getPageSource().contains(email);
}
}
package br.com.caelum.teste;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class NovoUsuarioPage {
private final WebDriver driver;
public NovoUsuarioPage(WebDriver driver) {
this.driver = driver;
}
public void cadastra(String nome, String email) {
WebElement txtNome = driver.findElement(By.name("usuario.nome"));
WebElement txtEmail = driver.findElement(By.name("usuario.email"));
txtNome.sendKeys(nome);
txtEmail.sendKeys(email);
txtNome.submit();
}
}
package br.com.caelum.teste;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.firefox.FirefoxDriver;
public class UsuarioSystemTest {
private FirefoxDriver driver;
@Before
public void inicializa() {
this.driver = new FirefoxDriver();
}
@Test
public void deveAdicionarUmUsuario() {
UsuariosPage usuarios = new UsuariosPage(driver);
usuarios.visita();
usuarios.novo().cadastra("Alisson B.", "alissonb@email.com");
assertTrue(usuarios.existeNaListagem("Alisson B.", "alissonb@email.com"));
}
@After
public void finaliza() {
driver.close();
}
}
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
at br.com.caelum.teste.UsuarioSystemTest.deveAdicionarUmUsuario(UsuarioSystemTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)