I'm trying to grab elements from a page but it's not found. Here is the code for the page:
<form method="POST" action="j_security_check" onsubmit="return(OnLoginSubmit());">
<input type="hidden" name="operation">
<div style="LEFT: 250px; POSITION: absolute; TOP: 200px">
<!--div style="LEFT: 250px; POSITION: absolute; TOP: 235px"-->
<table style="background-image: url(imagens/background_logon.gif); background-repeat: no-repeat" callpadding="0" cellspacing="0" height="285" width="410" border="0">
<tbody><tr>
<td align="center">
<table callpadding="0" cellspacing="5" height="auto" width="auto" border="0">
<tbody><tr>
<td colspan="2"> </td>
</tr>
<tr>
<td align="right">
<b><font color="#314E94">Usuário: </font></b>
</td>
<!-- Elemento que desejo pegar (j_username) -->
<td><input type="text" name="j_username" size="37" maxlength="7" onkeyup="mudaFoco('j_password', this.value, 7);"></td>
</tr>
<tr>
<td align="right"><b><font color="#314E94">Senha: </font></b></td>
<td><input type="password" name="j_password" size="37" maxlength="8" onkeyup="mudaFoco('Logar', this.value, 8);"></td>
</tr>
<tr>
<td colspan="2" align="center" style="padding-top: 30px">
<table callpadding="0" cellspacing="5" height="auto" width="auto" border="0">
<tbody><tr>
<td><input type="submit" value="Entrar" name="Logar" class="b1"></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</div>
</form>
Some attempts made:
navegador.findElement(By.name("j_username")).sendKeys("C001104");
or
navegador.findElement(By.xpath("//form//input[@name=\"j_username\"]")).sendKeys("C001104");
Nothing worked. The error:
TRACE: no such element: Unable to locate element: {"method": "name", "selector": "j_username"} (Session info: chrome = 54.0.2840.99) (Driver info: chromedriver = 2.27.440174 Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20: 26: 55.152Z' System info: host: 'DF7390ET123', ip: '10 .208.22.149 '. 'java.version:' 1.8.0_131 'Element info: {Using = name, value = j_username}