尝试在Stack上发布的所有内容,甚至mshtml.IHTMLElement nativeElement = el
作为mshtml.IHTMLElement;
nativeElement.click()
无效。
以下代码是标准代码,适用于WebBrowser
控件中的其他按钮点击。
HtmlElementCollection pageTextElements = doc.Window.Document.GetElementsByTagName("input");
HtmlElement btnOK = null;
foreach (HtmlElement element in pageTextElements)
{
if (element.Id == "btnOK")
{
btnOK = element;
}
}
btnOK.InvokeMember("click");
//这是我试图点击的按钮:
<input id="btnOK" class="btn12" type="submit" value="OK" title="" tabindex="11" style="position: absolute; left: 584px; height: 21px; width: 63px; …pointer; top: 1074px; padding-left: 0px; padding-right: 0px;" onfocus="saveFocusedControl("btnOK");" name="btn_btnOK" alt="OK" accesskey="O"></input>
答案 0 :(得分:0)
if (webBrowser1.ReadyState == System.Windows.Forms.WebBrowserReadyState.Complete)
{
System.Threading.Thread.Sleep(100);
System.Windows.Forms.Application.DoEvents();
btnOK.InvokeMember("click"); //Go back to Select Date for TimeSheet...Original Url...
}