0

我正在使用 VB.Net,我正在使用 WebBrowser1.Document.GetElementById("submit").InvokeMember("click")

但我似乎无法找到实际的 ID。我正在尝试从网站上找到登录按钮 ID:http ://grooveshark.com/#!/login

有什么解决办法吗?

4

2 回答 2

0

尝试这个:

Public Sub ClickSearching(ByVal targetType As String, ByVal targetText As String)
    Dim bFounded As Boolean = False
    Dim tags As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName(targetType)

    For Each elem As HtmlElement In tags
        Application.DoEvents()

        If elem.GetAttribute("value") = targetText Then
            elem.InvokeMember("click")
            bFounded = True
            Exit For
        End If
    Next

    If Not bFounded Then
        Throw New Exception("No se encontró ningún resultado para la función ClickSearching(" & targetType & "," & targetText & ")")
    End If
End Sub
于 2013-05-13T07:29:34.317 回答
0

你可以像这样得到所有按钮

WebBrowser1.Document.GetElementsByTagName("button")

相反,提交表单可能更容易。

Dim form As HtmlElement = WebBrowser1.Document.GetElementById("formId")

If form IsNot Nothing Then
        form.InvokeMember("submit")
End If
于 2013-05-13T03:49:32.450 回答