开发者

C# WebBrowser1 Click A Href - How To

I have a WebBrowser1 object. I can load page successfully. I want to click an a href element. It has to be same as user click because it executes some javascripts. How can i do that ?

Microsoft Visual Studio 2010 C# .net 4.0

开发者_运维问答

Thank you.


if the element has an id like this

<a href="http://www.yahoo.com" id="hrefId">TestLink</a> 

you can do something like this.

var element = webBrowser1.Document.All["hrefId"];
if(element != null )
{
    webBrowser1.Select();
    element.Focus();
    SendKeys.Send("{ENTER}");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜