VB.Net Finding class ID to click when it's buried in the DOM

170 Views Asked by At

Example of the tree I'm dealing with

I am trying to click the 'followers' button on an IG account I run to see see the new users who have followed me automatically. (The example in the included picture is not my account for privacy reasons) I can find the class ID, but using something like

 Dim allelements As HtmlElementCollection = webBrowse.Document.All
    For Each webpageelement As HtmlElement In allelements
        If webpageelement.GetAttribute("class") = "g47sy " Then
            webpageelement.InvokeMember("click")
        End If
    Next

returns nothing for me... I know it's because this class is buried in JS and then further down the line. I can't for the life of me figure out how to check the elements of something buried so far in..

Any help would be super appreciated! Thank you!

1

There are 1 best solutions below

0
On

Posted by Jimi in comments:

GetElementsByTagName() where the TAG name is SPAN, Then .GetAttribute("className"), not "class". Using LINQ, you can just add a .Where or FirstOrDefault clause to the collection returned by GetElementsByTagName() to single one out directly. – Jimi 12 hours ago