Does not take elements with Selenium in Chrome

Asked

Viewed 100 times

0

I’m trying to get elements from a page but it’s not found. Follow the code of 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">&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>

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 out. The mistake:

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', os.name: 'Windows 8', os.Arch: 'amd64', os.version: '6.2', java.version: '1.8.0_131' Element info: {Using=name, value=j_username}

  • 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', os.name: 'Windows 8', os.Arch: 'amd64', os.version: '6.2', java.version: '1.8.0_131' Element info: {Using=name, value=j_username}

  • To add information, you can [Dit] the question, is much more readable than in the comments. See also how to better format the question on Help Center

No answers

Browser other questions tagged

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