Flash Atölyesi
Flash Atölyesi

Reputation: 159

Button click not working in GeckoFX (C#)

I have some button on page, click command not navigate page.

Debug console writes "IsWindowModal" Any ideas to solve this? Thanks

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();
     }
}

Upvotes: 1

Views: 909

Answers (1)

Bartosz
Bartosz

Reputation: 4766

You can trigger the 'onclick' event rather than trying to click programmatically.

    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);
     }

Upvotes: 1

Related Questions