如何在vb.net windows窗体按钮控件中单击网页中的按钮 [英] How to click a button in a webpage in vb.net windows form button control
本文介绍了如何在vb.net windows窗体按钮控件中单击网页中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有web浏览器控件和按钮的窗体。
我 当我点击windows窗体中的按钮时,需要点击网页上的按钮。
网页上按钮的源代码是
I have a windows form with a webbrowser control and button.
I need to click button on webpage when I click the button in windows form.
The source code of the button on the webpage is
<button class="bin btn-block btn-md btn-success btn-embossed" data-toggle="modal" onclick="formSubmitAjax();" >....</button>
我想我不能使用getelementbyid因为没有ID而且有onclick =formSubmitAjax();
I guess I cannot use getelementbyid as there is no ID and there is onclick="formSubmitAjax();"
推荐答案
你好
使用下面的代码,我在webbrowser控件中按设计加载www.google.com url,在windows窗体中单击按钮添加以下代码
Hi Use following code,i am load www.google.com url in webbrowser contorl by design,in windows form button click event add below code
if (webBrowser1.Url.Host.EndsWith("google.com")) {
HtmlDocument doc = webBrowser1.Document;
HtmlElement ask = doc.All["q"];
HtmlElement lucky = doc.All["btnI"];
ask.InnerText = "stackoverflow";
lucky.InvokeMember("click");
}
这时当你点击windows按钮时,它会自动在搜索栏中添加stackoverflow测试并点击搜索按钮google.com网站。
问候
Aravindb
Here when u click windows button it automatically add "stackoverflow" test in search bar and it click search button of google.com website.
Regards
Aravindb
这篇关于如何在vb.net windows窗体按钮控件中单击网页中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文