title: VB.Net - select a class using GetElementByClass and then click the item programmatically
body: <p>Now before posting this question i did read...</p>
  
  <p><a href="https://stackoverflow.com/questions/3436116/how-to-select-a-class-by-getelementbyclass-and-click-on-it-programmically">How to select a class by GetElementByClass and click on it programmically</a></p>
  
  <p>But this doesn't work for me. Apparently I'm an idiot and don't know how to use that code, or its just not working for me. I also am using the WebBrowser Control in VB.NET if that helps at all...</p>
  
  <p>I have the following I'm trying to click...</p>
  
  <pre><code>&lt;div class="closewindow"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Now of course this is buried below and inside tons and tons of other divs, but it doesn't have any direct "owner". There is no  or anything like that. Its just sitting by itself</p>
  
  <p>Here is the html its barried in</p>
  
  <pre><code>&lt;div class="main_class"&gt;  
  &lt;div id="FullItemView"&gt;  
  &lt;div style="width: 90%; float: left;"&gt;  
  &lt;div class="headline"&gt;  
  &lt;table style="width: 100%;"&gt;    
  &lt;tbody&gt;&lt;tr&gt;      
  &lt;td style="width: 15%; text-align: right; vertical-align: middle;"&gt;
  &lt;img class="switchImage" src="pictures/pic.png"&gt;&lt;/td&gt;      
  &lt;td style="width: 70%; vertical-align: middle;"&gt;
  &lt;span class="ListItemTitle"&gt;Renegade&lt;/span&gt;&lt;/td&gt;      
  &lt;td style="width: 15%; text-align: left;"&gt;
  &lt;img class="switchImage" src="pictures/pic.png"&gt;&lt;/td&gt;    &lt;/tr&gt;  &lt;/tbody&gt;&lt;/table&gt;  
  &lt;/div&gt;  
  &lt;/div&gt;  
  &lt;div class="closeWindow"&gt;&lt;/div&gt;
  ......
  </code></pre>
  
  <p>Now I just want to be able to single out the  and then invoke a "click" on this div and this div only. I know when its being clicked because of some PHP code thats on the server, but that would take too long to explain how that works.</p>
  
  <p>Anyone know how i can single this out so when i have a variable XITEM or something inside .NET then i can invoke it? Like if I had ...</p>
  
  <pre><code>For XITEM as HTMLELEMENT in WebBrowser1.Document.GetElementsByTagName("div")
  ......
  item.invokeMember("click")
  .....
  </code></pre>
  
  <p>Then it clicks only the HTMLELEMENT "chosen". Hopefully this makes sense to everyone</p>