Sunday 12 August 2012

log in page using vb.net part 1


n this tutorial, we cover how to log into a website by interacting with HTML elements in a page using the element ID. Don’t worry if you don’t quite understand it yet, there are a few more tutorials that will explain it in more depth. Interacting with HTML elements is a good way to create a bot that will automate web page tasks. Login a page is accessing (remotely accessing webpage or login ny user name and password)

Explain each line by line
      Give login page address in web browser navigation bar and click go
        Set your  attribute  like username (user) and password
      Click 2nd button to login remotely from your application
       Make text box to enter data and labels for good user interface

     In first line webbrowser1.navigate is your web browser in application if you don’t know how to add web browser see some (I added posts about webbroswer) article explain how to add web browser and that web browser is navigate to your login page and from there to login your page using application
     Get element by id is to get an class of and attribute and set value you given for login
     Same as the password attribute and save
Copy and paste below Code:

Public Class Form1



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        WebBrowser1.Navigate("http://login.yahoo.com/")

    End Sub



    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        WebBrowser1.Document.GetElementById("login").SetAttribute("value", TextBox1.Text)

        WebBrowser1.Document.GetElementById("passwd").SetAttribute("value", TextBox2.Text)



        WebBrowser1.Document.GetElementById(".save").InvokeMember("click")

    End Sub



End Class