如何解决Powershell问题自动登录按钮按下

时间:2019-07-06 18:06:46

标签: html powershell

我正在尝试运行Powershell自动填充用户名和密码,然后单击“登录”按钮。我设法将其填充到2个字段中,但是无法弄清楚如何使登录按钮起作用。

这是HTML:

<div class="row-fluid">
    <div class="span6 offset3 login-form">
        <img src="./Data Retrieval_files/dataret-logo.png" alt="Direct Finance Group" href="/">                                        
        <form action="https://www.dfcdata.co.uk/2/" method="post" accept-charset="UTF-8" class="has-validation-callback">
            <div class="row-fluid">
                <div class="span2">
                    <h2>My Login</h2>
                </div>
                <div class="span4">
                    <input type="text" placeholder="Username" id="username" name="username" autocapitalize="off" autocorrect="off">
                </div>
                <div class="span4">
                    <input type="password" placeholder="Password" id="password" name="password" autocapitalize="off" autocorrect="off">
                    <a href="https://www.dfcdata.co.uk/2/forgotten-password" style="color: #cccccc;text-decoration: none">Forgotten Password?</a>
                </div>
                <div class="span2">
                    <button type="submit" class="btn dfc-btn red" name="login" value="login">Login</button>
                </div>
            </div>
        </form>
    </div>
</div>

powershell中的问题行是:

$Link=$ie.Document.getElementsByTagName("input") | where-object {$_.type -eq "btn dfc-btn red"}

$Link.click()

点击登录时出现的错误是:

You cannot call a method on a null-valued expression.
At line:1 char:1
+ $Link.click()

0 个答案:

没有答案