按钮单击Web浏览器 [英] Button click in web browser
本文介绍了按钮单击Web浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经通过点击按钮1的窗体上创建的网络浏览器,现在我想点击网页上的按钮。
I have created web browser, now i want to by clicking button1 on my form click the button on the web.
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("search").SetAttribute("value", IP.Text);
webBrowser1.Document.GetElementById("").InvokeMember("click");
}
但我不能从这个字符串得到一个按钮的ID
But i can't get a button id from this string
<input type="submit" value="→" class="button">
有没有办法解决这个问题的方法?
Is there a way to solve this problem?
推荐答案
尝试遍历所有的&LT的;输入&GT;
在网页中的元素。当你找到一个你想要的值,你可以单击该元素。
Try Iterating over all of the <input>
elements in the webpage. When you find one with the value you want, you could click that element.
foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("input")
{
if (el.GetAttribute("value").Equals("→"))
{
el.InvokeMember("click");
}
}
这篇关于按钮单击Web浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文