Estou enfrentando o seguinte erro ao tentar recuperar o elemento pelo id da tabela
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"#tabela-leiloes tbody tr:last-child"}
(Session info: chrome=106.0.5249.120)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
A tabela no arquivo index está com id
<table id="tabela-leiloes" class="table table-hover">
<thead>
<tr>
<th scope="col">Nome</th>
<th scope="col">Data de abertura</th>
<th scope="col">Valor inicial</th>
<th scope="col">Usuario</th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr th:each="leilao : ${leiloes}" >
<td scope="row" th:text="${leilao.nome}">Nome</td>
<td th:text="${#temporals.format(leilao.dataAbertura, 'dd/MM/yyyy')}">10/02/2020</td>
<td th:text="${leilao.valorInicial}">Valor Inicial</td>
<td th:text="${leilao.usuario.nome}">Nome do Usuario</td>
<td sec:authorize="isAuthenticated()" th:if="${leilao.usuario.nome != usuarioLogado.name && leilao.aberto}">
<a class="btn btn-block btn-info" th:href="@{'/leiloes/' + ${leilao.id}}" >dar lance</a>
</td>
<td sec:authorize="isAuthenticated()" th:if="${leilao.usuario.nome == usuarioLogado.name} ">
<a class="btn btn-block btn-primary m-0" th:href="@{'/leiloes/' + ${leilao.id}} + '/form'">editar</a>
</td>
</tr>
</tbody>
</table>
Classe de Leiloes page
package br.com.alura.leilao.leiloes;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class LeiloesPage {
private static final String URL_CADASTRO_LEILAO = "http://localhost:8080/leiloes/new";
private ChromeDriver browser;
public LeiloesPage(ChromeDriver browser) {
this.browser = browser;
}
public void fechar() {
this.browser.quit();
}
public CadastroLeilaoPage carregarFormulario() {
this.browser.navigate().to(URL_CADASTRO_LEILAO);
return new CadastroLeilaoPage(browser);
}
public boolean isLeilaoCadastrado(String nome, String valor, String hoje) {
WebElement linhaDaTabela = this.browser.findElement(By.cssSelector("#tabela-leiloes tbody tr:last-child"));
WebElement colunaNome = linhaDaTabela.findElement(By.cssSelector("td:nth-child(1)"));
WebElement colunaDataAbertura = linhaDaTabela.findElement(By.cssSelector("td:nth-child(2)"));
WebElement colunaValorInicial = linhaDaTabela.findElement(By.cssSelector("td:nth-child(3"));
return colunaNome.getText().equals(nome)
&& colunaValorInicial.getText().equals(valor)
&& colunaDataAbertura.getText().equals(hoje) ;
}
}
Não consigo identificar a inconsistência no código, caso alguém consiga me ajudar ficarei grato! Projeto completo : https://github.com/rodrigox/2061-testes-integracao-java