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

2019-08-18 23:18发布

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条回答
\"骚年 ilove
2楼-- · 2019-08-19 00:07

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.

查看更多
登录 后发表回答