Wednesday, August 6, 2014

Many ways Submit web form on a GeckoWebBrowser? (GeckoFX)

First one
 document = geckoWebBrowser1.Document; 

(document.GetElementByTagName("form").First() as GeckoFormElement).submit()

I can give example in c# :
If you know id value for input tags and login button , you can do this:
 GeckoInputElement username = new GeckoInputElement(geckoWebBrowser1.Document.GetElementById("Username_ID").DomObject);
 GeckoInputElement Passwd = new GeckoInputElement(geckoWebBrowser1.Document.GetElementById("passwd_ID").DomObject);
 GeckoInputElement Loginbutton = new GeckoInputElement(geckoWebBrowser1.Document.GetElementById("login_button_ID").DomObject);
 username.Value = "username";
 Passwd.Value = "password";
and if you know name of input tags, try this:
GeckoInputElement username = new GeckoInputElement(geckoWebBrowser1.Document.GetElementsByName("email")[0].DomObject);
GeckoInputElement password = new GeckoInputElement(geckoWebBrowser1.Document.GetElementsByName("pass")[0].DomObject);
GeckoInputElement login = new GeckoInputElement(geckoWebBrowser1.Document.GetElemntByName("login_name")[0].DomObject);
username.Value = "username";
password.Value = "password";
and if you dont know any id or name of input tags and have class name, try this,
GeckoNodeCollection nod = geckoWebBrowser1.Document.GetElementsByClassName("classname");
        foreach (GeckoNode node in nod)
            if (NodeType.Element == node.NodeType)

                    GeckoInputElement ele = (GeckoInputElement)node;
                catch (Exception ex)
                    string ep = ex.ToString();
                    GeckoHtmlElement ele = (GeckoHtmlElement)no2;

Taken from and as personal notepad. Credit belong