开发者

c# Web Browser simulate button press

开发者 https://www.devze.com 2023-02-23 13:31 出处:网络
I\'m 开发者_StackOverflow社区using the WebBrowser control and want to bypass a button press on a web page. I\'m not very familiar with HTMLand web pages, but I\'m wondering if anyone has a solution.

I'm 开发者_StackOverflow社区using the WebBrowser control and want to bypass a button press on a web page. I'm not very familiar with HTML and web pages, but I'm wondering if anyone has a solution.

The button I'm talking about is on this web page: http://www.movshare.net/video/ut55cfdvg5wgj/?

The button is appearing at random so it might not be there always.


Edit: Thinking about this, you can do most of this from the C#. Updated.

Get a reference to the button and invoke it's click() JavaScript method:

HtmlElement btn = myBrowserControl.Document.GetElementById("myButton");
/*
Alternatively, take a look at these other methods for retrieving an HtmlElement:
HtmlDocument.GetElementFromPoint(Point point)
HtmlDocument.GetElementsByTagName(string tagName)
HtmlDocument.All.GetElementsByName(string name)
*/
btn.InvokeMember("click");

This will only work in all browsers if ...
Since this is a WebBrowser control, you don't need to worry about cross browser issues.


Do you want the user to skip the button press everytime. Then this means, you don't need the button at all on the page. Please put more information

0

精彩评论

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