Click a form button inside webbrowser RRS feed

  • Question

  • Hi all.

    I am trying to extract data from some web page,  using webbrowser control, but first i have to login. I would like to login automaticly.

    On my web page, as you allready know, I have username and passwor fields that i can fill using following code:


    Me.WebBrowser1.Document.Forms(0).GetElementsByTagName("INPUT").Item(0).SetAttribute("VALUE", "user123")

    Me.WebBrowser1.Document.Forms(0).GetElementsByTagName("INPUT").Item(1).SetAttribute("VALUE", "pass123")


    What i dont know is how to perform a click to the submit button. This is its html code:



    This code doesnt work:






    I have a working code:

    m_document = Me.WebBrowser1.Document

    Dim user As MSHTML.HTMLInputElement = Nothing

    Dim password As MSHTML.HTMLInputElement = Nothing

    Dim login As MSHTML.HTMLInputElement = Nothing

    Dim usercounter As Boolean = True


    For Each element As HtmlElement In m_document.GetElementsByTagName("input")

    If element.Name = "TELEFON" Then

    If usercounter = True Then

    user = element.DomElement

    usercounter = False

    End If

    ElseIf element.Name = "SIFRA" Then

    password = element.DomElement

    ElseIf element.Name = "PRIJAVA" Then

    login = element.DomElement

    End If

    Next element

    user.value = "user123"

    password.value = "pass123"



    But it uses MSHTML that i cant use later in compact framework.


    Is there any other (easier) way to do this ?

    Something like ...


    Saturday, September 2, 2006 6:23 PM


All replies

  • There may be a better way!

    However, when faced with a similar problem I used an SSL secured web service to -

    1.       Authenticate the user with the current app credentials

    2.       Return a one time use security token (with limited lifetime validity specified in milliseconds)

    3.       Passed that token as a parameter to the login page

    4.       The login page checked for the token parameter

    5.       Retrieved the associated user

    6.       Deleted the one time use key

    7.       Authenticated browser based on appropriate user


    Sunday, September 3, 2006 3:23 AM
  • In a simple case when "login" element only submits the form you can use:

    Thursday, November 30, 2006 11:09 AM
  • Thursday, November 30, 2006 1:33 PM