.net website form filling program error
I'm trying to write a quick vb.net script that logs me into a website once
I press a button in the program. The code is below.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate("http://www.website.com")
Dim htmlElements As HtmlElementCollection =
WebBrowser1.Document.GetElementsByTagName("input")
For Each el As HtmlElement In htmlElements
If el.GetAttribute("name").Equals("Username") Then
el.SetAttribute("value", "123")
End If
Next
End Sub
The problem is I get an error ("A first chance exception of type
'System.NullReferenceException' occurred in program.exe")
Can anyone help me fix this?
No comments:
Post a Comment