VB.NET - 单击Webbrowser页面上的"提交"按钮

8 browser vb.net input

我在我的webbrowser对象上打开了一个html页面,我可以输入用户名和密码,但我卡住了,不知道如何提交信息.这是用户名/密码提交的html代码:

<div id="signin">
    <h2 class="ir">
        <em></em>Sign in</h2>
    <form action="/login/" method="post">
    <input id="login-url" name="login[url]" 
           type="hidden" value="/characters/" />
    <input id="login-urlError" name="login[urlError]" 
           type="hidden" value="/account/?error=1" />
    <fieldset>
        <ul>
            <li class="row">
                <label for="login-username">
                    Username <span class="req">*</span>
                </label>
                <input id="login-username" name="login[username]"
                        type="text" class="TextBox" value="" />
            </li>
            <li class="row">
                <label for="login-password">
                    Password <span class="req">*</span>
                </label>
                <input id="login-password" name="login[password]"
                       type="password" class="TextBox Password" value="" />
            </li>
            <li class="but">
                <input name="login[submit]" type="image" 
                       class="img" alt="Login &raquo;" 
                       src="/_pub/img/hp/but-login.png" />
            </li>
        </ul>
    </fieldset>
    </form>
    <p>
        <a href="/account/password-reset/">ACCOUNT TROUBLE?</a>
    </p>
</div>
Run Code Online (Sandbox Code Playgroud)

我使用以下命令输入用户名和密码:

WebBrowser1.Document.GetElementById("login-username").SetAttribute("Value", Information.txtuser.Text)
WebBrowser1.Document.GetElementById("login-password").SetAttribute("Value", Information.txtpass.Text)
Run Code Online (Sandbox Code Playgroud)

我现在应该用什么来提交信息?我尝试按名称获取元素并保持索引超出范围错误,索引应为-1或0,但它是.

你的帮助会非常有用!

cde*_*zaq 0

您可以尝试为表单提供一个 ID,以便获取它,然后从 Javascript 调用中调用 form.submit()。