Help to catch the element by the Selenium xpath

Asked

Viewed 361 times

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">&nbsp;</td>
                   </tr>
                    <tr>
                        <td align="right">
                            <b><font color="#314E94">Usuário:&nbsp;</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:&nbsp;</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 by name or by CSS selector?

  • find_element_by_name doesn’t work?

  • Does not work, shows the following error:org.openqa.Selenium.Nosuchelementexception: no such element: Unable to locate element: {"method":"name","selector":"j_username"}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.