[ACCEPTED]-How to click a link element programmatially with HTMLElement?-webforms
You have to find your element first, by 3 its ID or other filters:
HtmlElement fbLink = webBrowser.Document.GetElementByID("fbLink");
And to simulate 2 "click":
fbLink.InvokeMember("click");
An example for finding your link 1 by inner text:
HtmlElement FindLink(string innerText)
{
foreach (HtmlElement link in webBrowser.Document.GetElementsByTagName("a"))
{
if (link.InnerText.Equals("Google Me"))
{
return link;
}
}
}
You need a way to automate the browser then.
One 10 way to do this is to use Watin (https://sourceforge.net/projects/watin/). It allows 9 you to write a .Net program that controls 8 the browser via a convenient object model. It 7 is mainly used to write automated tests 6 for web pages, but it can also be used to 5 control the browser.
If you don't want to 4 control the browser this way then you could 3 write a javascript that you include on your 2 page that does the clicking, but I doubt 1 that is what you are after.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.