How to invoke click on a link in the web browser?

若如初见. 提交于 2019-12-25 10:00:12

问题


Okay lets say the page contains a link called 'About Us'. Instead of me doing:

webBrowser.Navigate ("www.page.com/aboutus");

...how can I tell my program to click any link that contains the text About Us?

I know this might seem like Im doing more work then necessary I have too but trust me I need this bit of code.

Any help would be appreciated, thanks :)


回答1:


You need to find the HtmlElement object for the <a> tag, then call InvokeMember("click").

If the element has an ID, you can get it by calling Document.GetElementById; otherwise, you can look through GetElementsByTagName and find the element you're looking for.



来源:https://stackoverflow.com/questions/7300502/how-to-invoke-click-on-a-link-in-the-web-browser

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