Results 1 to 5 of 5

Thread: [RESOLVED] Webbrowser - Invoke click without having a name?

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    51

    Resolved [RESOLVED] Webbrowser - Invoke click without having a name?

    Alright, all I want to do is submit a form on this website.
    The program is simple enough - automatically logs me into the site.
    For reference; the website is ( http://kingsofchaos.com )
    I know, the game is lame.. I enjoy it though xD

    Anyway, I have already figured out how to fill in User/Pass fields.
    But I am having problems understanding how to access the Login button.
    It should be simple, but the button itself is not assigned a name at all.
    Here is the only information given on the button itself ><
    Code:
    <input class="login_input" value="Login" style="width: 50px;" type="submit">
    WebBrowser1.Document.All(" -?- ").InvokeMember("click")

    ^ This is the code I assume would work pending it had a name.
    How ever, it does not have a name - so what do I do?
    If anyone knows any alternative methods I would really appreciate it.

    Thanks in advance!

  2. #2
    Addicted Member
    Join Date
    Jan 2008
    Posts
    162

    Re: Webbrowser - Invoke click without having a name?

    use diff identifier

    Code:
     
    For Each he As HtmlElement In WebBrowser1.Document.All
    If he.GetAttribute("value") = "Login" Then
                        he.InvokeMember("click").ToString()
    Thats it mate

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Webbrowser - Invoke click without having a name?

    Don't forget to exit the loop after invoking the click on the button. Otherwise, you may end up submittingthe form more than once (some web pages has more than 1 submit buttons on them).
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Webbrowser - Invoke click without having a name?

    you could also grab the form element and call its submit method, versus grabbing the submit button element, and callings its click method.

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    51

    Re: Webbrowser - Invoke click without having a name?

    Michalss example worked perfectly, well almost perfectly!


    Code:
            For Each Unit As HtmlElement In WebBrowser1.Document.All
                If Unit.GetAttribute("value") = "Login" Then
                    he.InvokeMember("click")
                End If
            Next
    ^ This is the actual code that I am using in my application.
    Works perfectly, does exactly what I wanted it to.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width