C#单击具有相同id的html按钮
谁能帮帮我吗。 我需要知道如何使用webbrowser自动生成表单,只需单击包含“报告”文本的按钮即可。 我不能用ID,因为他们都有“发送”IDC#单击具有相同id的html按钮,c#,html,automation,click,send,C#,Html,Automation,Click,Send,谁能帮帮我吗。 我需要知道如何使用webbrowser自动生成表单,只需单击包含“报告”文本的按钮即可。 我不能用ID,因为他们都有“发送”ID this.form.target=''; this.form.action='/foglioorario.php'; 这个.form.submit();“>地拉那 阿尔法:% TMS: 暂停: 展示区: 我想我明白你的意思,如果这对你有效,请告诉我 IHTMLElementCollection buttonCol = doc.getElementsBy
this.form.target='';
this.form.action='/foglioorario.php';
这个.form.submit();“>地拉那
阿尔法:%
TMS:
暂停:
展示区:
我想我明白你的意思,如果这对你有效,请告诉我
IHTMLElementCollection buttonCol = doc.getElementsByTagName("input");
foreach (IHTMLElement btn in buttonCol)
{
if (btn.getAttribute("value") == "Report")
{
btn.click();
break;
}
}
你的回答救了我一命,我只是稍微修改了一下,没有使用mshtml。 这就是我使用它的方式:
WebBrowser wb = webBrowser1;
var doc = wb.Document;
HtmlElementCollection el = doc.GetElementsByTagName("input");
foreach (HtmlElement btn in el)
{
if (btn.GetAttribute("value") == "Report")
{
btn.InvokeMember("click");
break;
}
}
很好,thnx您的示例中混合了javascript和html,您能解释一下是什么吗?
WebBrowser wb = webBrowser1;
var doc = wb.Document;
HtmlElementCollection el = doc.GetElementsByTagName("input");
foreach (HtmlElement btn in el)
{
if (btn.GetAttribute("value") == "Report")
{
btn.InvokeMember("click");
break;
}
}