Click on Button using Selenium Basic with VBA

Asked

Viewed 274 times

-1

I’m trying to do an automated data search on a page of my work, and I can’t get past the login part, I can enter Login and Password, but all attempts to access the "Sign in" button are in vain. I’m starting out in this world, so I’m sorry about the code.

Basically the entry page has only the elements: Login, password and the login button.

Follow the page source code:

<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>nome</title>
<meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" />
<link type="text/css" rel="stylesheet" href="css/login.css" />
</head>
<body>
        <div id="header-line" class="header-line"></div>
<div style="width:100%;background-color:#0064ae;">
    <div style="width:100%" class="blue-gradient-background">
        <div  class="header-content">
            <table style="width:98%">
                <tr height="40px">
                    <td style="width:30%"><a href=""><img src="images/logo_x.png" alt="x" style="border: 0" /></td>
                    <td style="text-align: right; width: 40%"></td>
                    <td style="text-align: right; width: 30%;color:white;">
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
<div style="width:100%" class="silver-gradient-background">
    <div class="content">
        <table style="width: 100%">
            <tr height="30px">
                <td style="text-align: right; width: 10%"></td>
            </tr>
        </table>
    </div>
</div>
        <div id="content" class="content">
            <form method="post" action="/x/login" enctype="application/x-www-form-urlencoded">

                <div class="form-content">
                    <center>

                        <h2>
                            <label class="header-title">Bem-Vindo ao x</label>
                        </h2>
                        <table>
                            <tr>
                                <td>Login:<td>
                                <td><input type="text" name="matricula" style="margin-left: 4px; font-size: 11px;" /><td>
                            </tr>
                            <tr>
                                <td>Senha:<td>
                                <td><input type="password" name="senha" style="margin-left: 4px; font-size: 11px;" /><td>
                            </tr>
                        </table>
                        <div style="width:500px;"><label style="color: red;width:100%;vertical-align: super; padding-left: 20px;"></label></div>
                        <div style="width:500px;"><button style="font-size: 11px;" type="submit">Entrar</button></div>
                    </center>
                </div>

            </form>
        </div>


        <div class="login-footer">

            <div class="silver-gradient-background">
                <table id="formFooter:j_idt43"
                    class="ui-panelgrid ui-widget no-border"
                    style="height: 35px !important; width: 100% !important; white-space: nowrap !important;"
                    role="grid">
                    <tbody>
                        <td style="text-align: center; width: 20%"><label
                            class="subtitle">© </label></td>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>

My code basically opens the IE(it has to be for him) and searches the data I need, but for that I have to be with the page already open. I would like to do something more efficient and open the page and log in.

Follow the code part:

internet.Navigate "site que quero entrar"
internet.Visible = True

While internet.Busy Or internet.ReadyState <> 4
DoEvents
Wend
internet.Document.all("matricula").innerText = MyLogin
internet.Document.all("senha").innerText = MyPass >até aqui tudo certo
internet.Document.TurbonetOss.acao.Value = "Entrar"
internet.Document.TurbonetOss.submit

1 answer

-1

Hello Try this code

internet.document.getElementsByTagName("input")(0).Click

Browser other questions tagged

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