49. Click Button Without ID
This tutorial is an extension of the previous tutorial which covered how to retrieve every HTML element in a web page. This tutorial will show you how to click a button that doesn’t have an ID.
Code
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load WebBrowser1.Navigate("http://login.facebook.com/login.php") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim allelements As HtmlElementCollection = WebBrowser1.Document.All For Each webpageelement As HtmlElement In allelements If webpageelement.GetAttribute("value") = "Log In" Then webpageelement.InvokeMember("click") End If Next End Sub End Class

