我试图在使用webbrowser控件打开的页面的搜索图标中调用“单击”,但是它不起作用。 “ icon_zoom”元素始终为null。我导航到的网页是:http://legendas.tv/ 提交元素名称为“ icon_zoom”。
Public Sub ClickElement(ByVal wb As WebBrowser, ByVal id As String)
If wb.Document Is Nothing Then Exit Sub
Do While True
If wb.Document.GetElementById(id) Is Nothing Then
' The debug allways go here and stay in looping
Application.DoEvents()
MsgBox("Element id " & id & "is nothing", MsgBoxStyle.Exclamation, "Id is Nothing")
Else
Exit Do
End If
Loop
If wb.Document.Window.Frames.Count > 0 Then
For Each hw As HtmlWindow In wb.Document.Window.Frames
hw.Document.GetElementById(id).InvokeMember("click")
Next
Else
wb.Document.Window.Document.GetElementById(id).InvokeMember("click")
End If
Application.DoEvents()
End Sub