How to select a class by GetElementByClass and click on it programmatically

前端 未结 4 899
无人及你
无人及你 2020-12-11 06:23

I have been trying to use this code to read the element by class in html/ajax knowing GetElementByClass is not a option in webBrowser.Document. I can\'t seem to get a return

4条回答
  •  天涯浪人
    2020-12-11 06:29

    Dim HtmlElementcolltwo As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("button")
            For Each eleme As HtmlElement In HtmlElementcolltwo
                ' Check the attributtes you want
                If eleme.GetAttribute("className") = "derrt_submit feed-zed-bff" Then
                    'Check even the text if you want
                    ' If elem.InnerText = "Sign In" Then
                    'Invoke your event
                    eleme.InvokeMember("click")
                    'End If
                End If
            Next
    

    This Also works instead of using "class" use "className"

提交回复
热议问题