immortall69 0 Newbie Poster

Basically i'd like to click this "button" only once in the div "data-aid="115553109754009608849"" (this button is present in every div, and has no name or id, but i can click it by his class if i can locate him or walk the entire DOM - just that i don't know how to do that). But when i execute this tiny bit of code, for some reason it doens't work.

Basically this is my action code:

Dim allelements As HtmlElementCollection = WebBrowser1.Document.All

    For Each webpageelement As HtmlElement In allelements
        If webpageelement.GetAttribute("data-aid") = "115553109754009608849"   Then
            For Each elem As HtmlElement In webpageelement.Children
                If elem.GetAttribute("className") = "mod-button" Then
                    elem.InvokeMember("click")
                    Exit For
                End If
            Next
        End If
    Next

Okay, so this is the HTML i'm dealing with, with all the parent divs of the button (note that i don't have any control over this document)

<html>
 <body>
  <div id=""body-container"">
   <div id=""page-container"">
    <div id=""content"">
     <div class=""branded-page-v2-container branded-page-base-bold-titles branded-page-v2-container-flex-width branded-page-v2-secondary-column-hidden"">
      <div class=""branded-page-v2-col-container"">
       <div class=""branded-page-v2-col-container-inner"">
        <div class=""branded-page-v2-primary-col"">
         <div class=""   yt-card  clearfix"">
          <div class=""branded-page-v2-primary-col-header-container branded-page-v2-primary-column-content"">
           <div class=""branded-page-v2-body branded-page-v2-primary-column-content"">
            <div id=""watch-response"">
             <div id=""watch-response-content"">
              <div id=""watch-discussion"">
               <div id=""comments embedded"">
                <div class=""comments-list"">
                 <div class=""comment-entry"">
                  <div data-aid=""101515802118596397194"">  ''<-- this is the closest parent with an identifiable unique id
                   <div class=""content"">
                    <div class=""comment-footer"">
                     <div class=""comment-footer-actions"">
                      <table class=""footer-button-bar"">
                       <tbody>
                        <tr>
                         <td class=""mod-button"">  ''<-- this is the button i'd like to push
                         </td>
                        </tr>
                       </tbody>
                      </table>
                     </div>
                    </div>
                   </div>
                  </div>
                 </div>
                </div>
               </div>
              </div>
             </div>
            </div>
           </div>
          </div>
         </div>
        </div>
       </div>
      </div>
     </div>
    </div>
   </div>
  </div>
 </body>
</html>

Absolutely any help would be much appreciated! Thanks :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.