I'm tiring to emulate the google search with gecko web browser. so far i have able to go to the google page and then search some thing like this:
geckoWebBrowser1.Navigate("https://www.google.com/");
await Task.Run(() => CheckDocumentLoaded());
var page = geckoWebBrowser1.Document.GetElementById("lst-ib");
(page as GeckoHtmlElement).Focus();
(page as GeckoInputElement).Value = "something";
now i simply want to click on the search button. so i added this to the first part:
var button = new GeckoButtonElement(geckoWebBrowser1.Document.GetElementById("mKlEF").DomObject);
button.Click();
but funny things happens. if i run this code after the first part nothing will happens. but if i created a button and put the code on it it works just fine.
private void Button1_Click(object sender, EventArgs e)
{
var button = new GeckoButtonElement(geckoWebBrowser1.Document.GetElementById("mKlEF").DomObject);
button.Click();
return;
}
but i have to click on button manually in order to make it work. its really confusing. i have no idea what causes this!!
NOTE:
you have to use this user agent if you want to the code works:
(Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko)
i don't want to use the
SendKeys.Send("{ENTER}")
.if i press the button programmatically its not work either.