Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Help on Invoking Click Event

Isip2Isip2 Member Posts: 16

I am currently doing a project that involves automated logging-in on web accounts. I used the webBrowser control for this purpose and so far everything is working fine.

However, the method I use is: webBrowser1.Document.GetElementById("btnSubmitURL").InvokeMember("click");

The problem comes in when the button elements do not have name or id properties. Is there a way to invoke the click event without knowing the name or id of the button element?

The only other method I know is GetElementFromPoint(), but it would be good if there is another way since this method requires knowledge on the coordinates of the button.

Thanks everyone.


  • PsightoplazmPsightoplazm Member Posts: 332 ✭✭
    Well you obviously can't tell something to click itself without knowing who to tell - but what the WebBrowser does do for you is it breaks everything down into a complete DOM hierachy. If you can identify anything about the structure of the page - like is it inside a table that has a particular name or whatever, then you can find your control.

    I think what you are looking for is just being able to submit a "Form" block element - and you can actually do that directly off of the form. You can also search for the only "submit" inside the child hierarchy the form.

    var m = new WebBrowser();
    m.DocumentCompleted +=
    // Grab the form and submit it
    var form = m.Document.GetElementById("MyForm");

    // or you can find the submit button inside the form...
    var controls = form.GetElementsByTagName("input");
    foreach (var c in controls.Cast())
    if (c.GetAttribute("type") == "submit")


  • Isip2Isip2 Member Posts: 16
    Wow great help.
    I better start thinking some more so I won't miss solutions like this.

    Thanks again Psightoplazm, I think this should work.
  • Isip2Isip2 Member Posts: 16

    I have a hopefully more difficult problem at hand. Is there a way to retrieve a dynamic image, say a banner, directly from the webBrowser control? It should be retrieved without making an additional web request since an additional request would change the image.

    For a more specific example, how can I load an image shown in the WebBrowser control into a PictureBox? The use of the ImageLocation property will not work since it will request the image from the server.

    Any idea?

Sign In or Register to comment.