Well eventually "System.Threading.Thread.Sleep(150);" did not work, and I noticed that for some reason
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
terminates itself before the Web Browser completely loads. In order to make sure that the pages is loaded what I did was to create a bool variable called "wait". Then I changed the code to the following:
wait = true;
webBrowser1.Navigate("www.google.com");
while (wait==true) { Application.DoEvents(); }
webBrowser1.Document.GetElementById("q").SetAttribute("value", searchTXT.Text);
//MessageBox.Show(webBrowser1.Document.GetElementById("q").GetAttribute("value"));
webBrowser1.Document.GetElementById("btnK").InvokeMember("click");
and I double clicked webBrowser1 and set its "completed" event to be wait=false; which worked perfectly fine for me.