【问题标题】:Button click not working in GeckoFX (C#)按钮单击在 GeckoFX (C#) 中不起作用
【发布时间】:2018-02-18 00:04:01
【问题描述】:

我在页面上有一些按钮,点击命令不导航页面。

调试控制台写“IsWindowModal”有什么办法解决这个问题吗?谢谢

GeckoElementCollection link2 = webBrowser1.Document.GetElementsByTagName("input");
foreach (GeckoHtmlElement item in link2)
{
    string aux = item.GetAttribute("onclick");
    if (aux != null && aux != "" && aux.Contains("form1"))
    {
          item.Click();
     }
}

【问题讨论】:

  • 您可以发布您尝试点击的元素的预期内部 html 吗?

标签: c# visual-studio gecko geckofx


【解决方案1】:

您可以触发“onclick”事件,而不是尝试以编程方式点击。

    string aux = item.GetAttribute("onclick");
    if (aux != null && aux != "" && aux.Contains("form1"))
    {
          DomEventArgs ev = browser.Document.CreateEvent("MouseEvent");
          Event webEvent = new Event(browser.Window.DomWindow, ev.DomEvent as nsISupports);
          webEvent.InitEvent("click", true, false);
          item.DispatchEvent(ev);
     }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 2018-11-10
    • 1970-01-01
    相关资源
    最近更新 更多