Here is the source
HTML Code:<td rowspan=2> </td><td><img src="http://www.locationary.com/web/img/LocationaryImgs/icons/txt_email.gif"></td> <td><input class="Data_Entry_Field_Login" type="text" name="inUserName" id="inUserName" size="25"></td> <td><img src="http://www.locationary.com/web/img/LocationaryImgs/icons/txt_password.gif"></td> <td><input class="Data_Entry_Field_Login" type="password" name="inUserPass" id="inUserPass"></td> <td style="padding-top:2"><input id="login@DEFAULT" type="image" src="http://www.locationary.com/web/img/LocationaryImgs/btn/white/btn_login_40x20_fff_normal.gif" onmouseover="javascript:this.src='http://www.locationary.com/web/img/LocationaryImgs/btn/white/btn_login_40x20_fff_highlighted.gif'" onmouseout="javascript:this.src='http://www.locationary.com/web/img/LocationaryImgs/btn/white/btn_login_40x20_fff_normal.gif'" value="Submit" alt="Login" ></td></tr>Everything works fine except the login, it gives me an "Object reference not set to an instance of an object" error.Code:Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Part 1: Use WebBrowser control to load web page WebBrowser1.Navigate("http://www.locationary.com") End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted ' Part 2: 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 = "inUserName" Then curElement.SetAttribute("Value", "myUsername") ElseIf controlName = "inUserPass" Then curElement.SetAttribute("Value", "myPassword") End If Next WebBrowser1.Document.GetElementById("login@DEFAULT").InvokeMember("click") End Sub End Class




Reply With Quote