0
Following code, I need help picking up element in Selenium: Elements name: j_username
and name: j_password
.
<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>
Why use
xpath
if you can get the element byname
or by CSS selector?– Renan Gomes
find_element_by_name
doesn’t work?– Laerte
Does not work, shows the following error:org.openqa.Selenium.Nosuchelementexception: no such element: Unable to locate element: {"method":"name","selector":"j_username"}
– izacjunior