0

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.

1 Answer 1

1

Don't put a "<" in front of the tag name "a".

use

wb.Document.GetElementsByTagName("a")

instead of

wb.Document.GetElementsByTagName("<a")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.