Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Part 1: Use WebBrowser control to load web page
WebBrowser1.Navigate("http://www.website.com/login.aspx")
System.Threading.Thread.Sleep(2000) ' Delay 2 seconds to render login page
' Part 2: Automatically input username and password
Dim theElementCollection As HtmlElementCollection
theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection
Dim controlName As String = curElement.GetAttribute("name").ToString
If controlName = "UserNameTextBox" Then
curElement.SetAttribute("Value", "Username text here")
ElseIf controlName = "PasswordTextBox" Then
curElement.SetAttribute("Value", "Password text here")
'In addition,you can get element value like this:
'MessageBox.Show(curElement.GetAttribute("Value"))
End If
Next
' Part 3: Automatically clck that Login button
theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("value").Equals("Login") Then
curElement.InvokeMember("click")
' javascript has a click method for you need to invoke on button and hyperlink elements.
End If
Next
End Sub
End Class