一个网站上有 17 个 HTML 按钮。这些按钮没有 ID,具有相同的名称、类型和值。我想通过使用 vb.net 2008 webbrowser 控件以编程方式单击按钮。当我写这段代码
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("website bla bla")
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
For Each webpageelement As HtmlElement In allelements
If webpageelement.GetAttribute("value") = "Start" Then
webpageelement.InvokeMember("click")
End If
Next
End Sub
End Class
然后每次,我的程序都会单击第 17 个按钮。我想单独单击第一个按钮,第二个按钮,第三个按钮等等,然后分别单击下一个按钮。所以你能指导我如何单独点击每个按钮。这是按钮的 HTML 代码。