How do i simulate a click event in a webbrowser control? .NET

自古美人都是妖i 提交于 2019-12-22 19:32:31

问题


So there is a button call next (page). Its href link is site/blah/#. So i know its really running javascript code. After i finish parsing the first page i would like to parse the next page. How do i simulate a mouse click there so i can continue loading and parsing pages?

i am using C# .NET


回答1:


childElement.RaiseEvent("OnClick");




回答2:


If you know the id of the tag you can use below given code

WebBrowser1.Document.GetElementById("submit").InvokeMember("click")

if you dont know the id you can follow this code

foreach (System.Windows.Forms.HtmlElement html in WebBrowser1.Document.GetElementsByTagName("a")) {
    if (html.InnerText == "YOUR TEXT") {
         html.InvokeMember("click");
    }
}

Contact if you have any doubt



来源:https://stackoverflow.com/questions/1161207/how-do-i-simulate-a-click-event-in-a-webbrowser-control-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!