Skip to content Skip to sidebar Skip to footer

Vb.net - Select A Class Using Getelementbyclass And Then Click The Item Programmatically

Now before posting this question i did read... How to select a class by GetElementByClass and click on it programmically But this doesn't work for me. Apparently I'm an idiot and d

Solution 1:

I figured it out after messin around with the original post that I found on stackoverflow.com

Dim theElementCollection As HtmlElementCollection = Nothing
        theElementCollection = WebBrowser1.Document.GetElementsByTagName("div")
        For Each curElement As HtmlElement In theElementCollection
            'If curElement.GetAttribute("classname").ToString = "example"  It doesn't work.  
            ' This should be the work around.
            If InStr(curElement.GetAttribute("classname").ToString, "closeWindow") Then
                ' Doesn't even fire.
                ' InvokeMember(test) after class is found.
                'MessageBox.Show(curElement.GetAttribute("InnerText"))
                curElement.InvokeMember("Click")
                curElement.InvokeMember("MouseDown")
                curElement.InvokeMember("MouseUp")
                curElement.RaiseEvent("OnClick")
                curElement.Focus()
            End If
        Next

Post a Comment for "Vb.net - Select A Class Using Getelementbyclass And Then Click The Item Programmatically"