VB.Net,无法单击按钮,无ID或名称

时间:2013-08-28 18:04:08

标签: html vb.net

我正在尝试为Adnooka获得一个平衡检查器,但我甚至无法通过登录。 这是HTML:

                                
        </div>
          <div class="control-group row-fluid">
          <label class="row-fluid " for="inputPassword">Password <div class="pull-right"><a class="muted"><small><a href='http://adnooka.com/recover'>Forgot your password ?</a></small></a></div></label>
          <div class="controls row-fluid input-append">
            <input type="password" id="inputPassword" placeholder="Password"  name="password" class="row-fluid" value=""> <span class="add-on"><i class="icon-lock"></i></span>
          </div>
        </div>
        <div class="control-group row-fluid fluid">
          <div class="controls span6">
          </div>
          <div class="controls span5 offset1" style=''>
            <button type='submit' class="btn btn-default" style='float:right'>Login<i class="gicon-chevron-right"></i></a>
          </div>
        </div>

但是按钮没有ID或名称,我该如何点击它? 如何返回余额的值?

这是我到目前为止所得到的:

    WebBrowser1.Document.GetElementById("email").SetAttribute("value", textbox1.Text)
    WebBrowser1.Document.GetElementById("password").SetAttribute("value", pass.Text)
    Dim allelements As HtmlElementCollection = WebBrowser1.Document.All

    For Each webpageelement As HtmlElement In allelements

        If webpageelement.GetAttribute("type") = "submit" Then

            webpageelement.InvokeMember("click")

        End If

    Next

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    WebBrowser1.Navigate("http://adnooka.com/login")
End Sub

1 个答案:

答案 0 :(得分:0)

您可以在表单上调用submit,而不必找到要点击的按钮。

如果页面上只有一个表单,这应该有效。如果没有,请将[0]调整为所需的任何内容:

WebBrowser1.Document.Forms[0].InvokeMember("submit")

有关详细信息,请参阅http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.forms.aspx