Estou tentando recuperar o texto exibido em uma tag na 10ª linha de código:
<ul data-v-4b5efaa2="" class="navbar-nav ml-auto d-flex flex-row-reverse justify-content-between">
<div data-v-7c97f2c5="" data-v-4b5efaa2="" class="dont-print cel-user-account">
<div data-v-7c97f2c5="">
<img data-v-7c97f2c5="" src="/img/user-photo.7601e3c8.png" alt="Foto do usuário" class="user-photo">
<span data-v-7c97f2c5="" class="sr-only">Menu do usuário</span><!---->
</div>
</div>
<span data-v-4b5efaa2="" class="nomeUsuario ml-auto mt-2">
<h6 data-v-4b5efaa2="">
***<strong data-v-4b5efaa2="" id="usuario-logado" name="usuarioLogado" class="text-primary">Teste User Admin</strong>***
</h6>
</span>
Trecho a baixo são as formas que já tentei recuperar a retorno um objeto vazio: OBS: usei um tipo de cada vez
public String getNomeUsuarioLogado() {
try {
String resposta = browser.findElement(By.id("usuario-logado")).getText();
//String resposta = browser.findElement(By.xpath("//*[@id='usuario-logado']")).getText();
//WebElement resposta = this.browser.findElement(By.id("usuario-logado"));
System.out.println(resposta);
return resposta;
} catch (NoSuchElementException e) {
return null;
}
}