提交按钮在GeckoFX中不工作
本文关键字:工作 GeckoFX 按钮 提交 | 更新日期: 2023-09-27 18:12:55
我有这样的代码:
<input type="button" onmousedown="IamTyping(0);" style="font-size:16px;" value="enter">
并在c#中尝试:
GeckoInputElement enter = new GeckoInputElement(myBrowser.Document.GetElementByTagName("input").DomObject);
enter.click();
c#没有任何错误,但它不能工作!
试试下面的代码
GeckoInputElement enter = (GeckoInputElement)myBrowser.Document.GetElementsByTagName("input")
.First(inp => ((GeckoInputElement)inp).Value == "enter");
DomEventArgs ev = browser.Document.CreateEvent("MouseEvent");
ev.DomEvent.InitEvent(new nsAString("mousedown"), true, true);
enter.GetEventTarget().DispatchEvent(ev);
ev = browser.Document.CreateEvent("MouseEvent");
ev.DomEvent.InitEvent(new nsAString("mouseup"), true, true);
enter.GetEventTarget().DispatchEvent(ev);
enter.click();