Quando executo o LeiloesSystemTest.java está aparecendo o seguinte log:
org.openqa.selenium.NoSuchElementException:Cannot locate element with text: Paulo Henrique
For documentation on this error, please visit:http://seleniumhq.org/exception/no_such_element.html
Build info: version:'3.5.3', revision:'a88d25fe6b', time:'2017-08-29T12:54:15.039Z'
System info: host: 'QED5782', ip: '10.0.30.6', os.name:'Windows 7', os.arch:'amd64',os.version:'6.1',java.version:'1.8.0_144'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.Select.selectByVisibleText(Select.java:151)
at br.com.caelum.teste.NovoLeilaoPage.preenche(NovoLeilaoPage.java:38)
at br.com.caelum.teste.LeiloesSystemText.deveCadastrarUmLeilao(LeiloesSystemText.java:30)
E fica em vermelho a linha abaixo:
novoLeilao.preenche("Geladeira", 123, "Paulo Henrique", true);
Segue abaixo código:
public class LeiloesSystemTest {
private WebDriver driver;
private LeiloesPage leiloes;
@Before
public void inicializa() {
this.driver = new FirefoxDriver();
leiloes = new LeiloesPage(driver);
UsuariosPage usuarios = new UsuariosPage(driver);
usuarios.visita();
usuarios.novo().cadastro("Paulo Henrique","paulo@henrique.com");
}
@Test
public void deveCadastrarUmLeilao() {
leiloes.visita();
NovoLeilaoPage novoLeilao = leiloes.novo();
novoLeilao.preenche("Geladeira", 123, "Paulo Henrique", true);
assertTrue(leiloes.existe("Geladeira", 123, "Paulo Henrique", true));
}
}
----------------------------------------------------------------------------------------------
public class NovoLeilaoPage {
private WebDriver driver;
public NovoLeilaoPage(WebDriver driver) {
this.driver = driver;
}
public void preenche (String nome, double valor, String usuario, boolean usado) {
WebElement txtNome = driver.findElement(By.name("leilao.nome"));
WebElement txtValor = driver.findElement(By.name("leilao.valorInicial"));
txtNome.sendKeys(nome);
txtValor.sendKeys(String.valueOf(valor));
Select cbUsuario = new Select(driver.findElement(By.name("leilao.usuario.id")));
cbUsuario.selectByVisibleText(usuario);
if (usado) {
WebElement ckUsado = driver.findElement(By.name("leilao.usado"));
ckUsado.click();
}
txtNome.submit();
}
}
----------------------------------------------------------------------------------------------
public class LeiloesPage {
private WebDriver driver;
public LeiloesPage(WebDriver driver) {
this.driver = driver;
}
public void visita() {
driver.get("http://localhost:8080/leiloes");
}
public NovoLeilaoPage novo() {
driver.findElement(By.linkText("Novo Leilão")).click();
return new NovoLeilaoPage(driver);
}
public boolean existe(String produto, double valor, String usuario,
boolean usado) {
return driver.getPageSource().contains(produto) &&
driver.getPageSource().contains(String.valueOf(valor)) &&
driver.getPageSource().contains(usado ? "Sim" : "Não");
}
}
----------------------------------------------------------------------------------------------
O que significa este erro?