日期:2014-05-17 浏览次数:21078 次
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim CurrentWindow As HtmlWindow = WebBrowser1.Document.Window
For Each Frame As HtmlWindow In CurrentWindow.Frames 'Get all frames
If Frame.Name = "Searchbar" Then
Dim btnElementCollection As HtmlElementCollection = Frame.Document.GetElementsByTagName("Input")
For Each curElement As HtmlElement In btnElementCollection
Dim controlName As String = curElement.GetAttribute("Name").ToString
If controlName = "txtSearchFor" Then
curElement.SetAttribute("Value", "Search fior text")
ElseIf controlName = "btnGo" Then
curElement.InvokeMember("Click")
End If
Next
End If
Next
End Sub