1

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!

user2261192
  • 13
  • 1
  • 6
  • `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 Mar 14 '19 at 06:58
  • Thank's so much! I was able to figure it out with your help. I need to click on that element which wasn't working. I had to give it an id to be able to click it. `webpageelement.setattribute("id", "WhateverName")` – user2261192 Mar 14 '19 at 19:06
  • I can't say I know how to use LINQ yet, but will try to figure that out. – user2261192 Mar 14 '19 at 19:12
  • You don't need to give it an ID first. If you have located the element just call `InvokeMember("click")` on it like you already do. What you need to change in your code is to check the **`className`** attribute rather than `class`, and correct the casing of the last two letters (it's `g47SY` rather than `g47sy`). – Visual Vincent Mar 15 '19 at 14:36

1 Answers1

0

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

user2261192
  • 13
  • 1
  • 6