I have been trying to execute a button event in html page that displays additional content on the web page. I am getting a null reference error when using the getelementbyid and not sure how to change this. Here is the html reference I need to engage:
<div class="button" style="float:none;width:180px;margin:20px auto 30px;"><a href="#" id="more" style="width:178px">Show more ▼</a></div>
</div>
and here is my code:
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
I appreciate any ideas.