You are getting the error on line
b.Document.GetElementById("gbqfq").InnerText = "programming";
This is because there is no Element called
gbqfq
so
b.Document.GetElementById("gbqfq")
is null.
You can't assign values to properties (e.g.
.InnerText
) of null objects.
You need to check for success find first e.g.
private void web_h(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser b = (WebBrowser)sender;
HtmlElement h1 = b.Document.GetElementById("gbqfq");
if (h1 != null)
h1.InnerText = "programming";
h1 = b.Document.GetElementById("gbqfba");
if (h1 != null)
h1.InvokeMember("click");
}