0
我一直试图在html页面中执行一个按钮事件,该页面在网页上显示额外的内容。我在使用getelementbyid时得到空引用错误,不知道如何改变它。下面是HTML参考我需要从事:在html中实现按钮点击
<div class="button" style="float:none;width:180px;margin:20px auto 30px;"><a href="#" id="more" style="width:178px">Show more ▼</a></div>
</div>
这里是我的代码:
Dim wb As New WebBrowser
wb.Navigate(fromUrl)
While wb.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
End While
Debug.Write(wb.DocumentText)
Dim htmlElements As HtmlElementCollection = wb.Document.GetElementsByTagName("<a")
If Not wb.Document Is Nothing Then
Try
If wb.DocumentText.Contains("more") Then
If wb.Document.GetElementById("more").GetAttribute("href") Then
wb.Document.GetElementById("more").InvokeMember("#")
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message.ToString)
End Try
End If
我明白任何想法。