I am trying to figure out how to click a button on a web page
programmatically.

Specifically, I have a WinForm with a WebBrowser control.  Once it
navigates, in the DocumentCompleted event handler I have the following
set up for logging in:

HtmlDocument doc = webBrowser1.Document;

HtmlElement userID = doc.GetElementById("userIDTextBox");
userID.InnerText = "user1";

HtmlElement password = doc.GetElementById("userPasswordTextBox");
password.InnerText = "password";

HtmlElement button = doc.GetElementById("logonButton");
button.RaiseEvent("onclick");

This fills the userid and password text boxes fine, but I am not having
any success getting that darned button to click; I've also tried
"click", "Click", and "onClick" -- what else is there?.  A search of
msdn of course gives me no clues, nor groups.google.com.  I gotta be
close.

The button is coded:

<input type="submit" name="logonButton" value="Login" onclick="if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); "
language="javascript" id="logonButton" tabindex="4" />

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to