简体   繁体   中英

VB.NET GetElementByTagName Doesn't work

i want to press a button in a website with the InvokeMember("click") code. Basically the websites html code is this one :

                   <em class='coins'>
                    <span class="click"></span>

And i tried using the answer found HERE but it doesn't seem to work. Do you know why? Am i doing something wrong?I also used the

If elem.InnerText = "Login" Then

but it didn't seem to help either. Here is the code in my Windows Form Application in Visual Studio :

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    For Each elem As HtmlElement In WebBrowser1.Document.GetElementsByTagName("span")

        If elem.GetAttribute("class") = "click" Then

                elem.InvokeMember("click")
            End If
        End If
    Next
End Sub

Sorry if this question counts as a duplicate, it is not the same as the other i made

I think you must use (className) and (.Equals() for two strings) like this code:-

    If elem.GetAttribute("className").Equals("free-coins-click") Then

            elem.InvokeMember("click")
        End If
    End If

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM