8

Using the WebBrowser control I am able to call an event when the mouse button is manually clicked, but I want the program to do the click itself, not do something when I manually perform the click.

For example, if I provide the ID of a control on the page I want the program to click it.

Here's what I have so far:

HtmlElement button = webBrowser1.Document.GetElementById("lButtonSearch"); button.Click += new HtmlElementEventHandler(GotoSearchPage); 
1
  • Is this to build a web app/site test harness by any chance? :) Commented Mar 1, 2011 at 4:59

1 Answer 1

16

Quite easily, simply use:

button.InvokeMember("click"); 
Sign up to request clarification or add additional context in comments.

2 Comments

@Nick - Sure, no problem. If you're doing any kind of (medium->high scale) Automation, I do recommend looking at WatiN (watin.sourceforge.net). Great project.
I looked at WatiN shortly after and have been using it ever since for many projects, thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.