Tried everything that was posted on Stack, even mshtml.IHTMLElement nativeElement = el
as mshtml.IHTMLElement;
nativeElement.click()
didn't work.
This code below is standard and works for me on other button clicks in the WebBrowser
control.
HtmlElementCollection pageTextElements = doc.Window.Document.GetElementsByTagName("input");
HtmlElement btnOK = null;
foreach (HtmlElement element in pageTextElements)
{
if (element.Id == "btnOK")
{
btnOK = element;
}
}
btnOK.InvokeMember("click");
//This is the button I'm trying to 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>
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...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.