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.
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();
// 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")
I better start thinking some more so I won't miss solutions like this.
Thanks again Psightoplazm, I think this should work.
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.