So im working on my gmail application which will allow me to log in to my gmail with ease. And what I have here is a webBrowser control and some HtmlElements to store some data in memory.
When I try to run this (When I press the Connect event) I keep getting this error.
System.NullReferenceException: 'Object reference not set to an instance of an object.'
Now what I think this is, is that its not finding the propper ID even though it is the correct one. but thats why im here im probably wrong. The first two elements works just fine, It typed in the email adress and clicks next but as soon as its going to type into the password field it throws that exception.
private void btnConnect_Click(object sender, EventArgs e)
{
//httpwebrequest
//find elementID
//invoke the variable to the elementID
//Elements - EmailID = Email | PasswordID = Passwd
//
HtmlDocument doc = webBrowser1.Document;
HtmlElement usernameElement = doc.GetElementById("Email");
HtmlElement loginBtnElement = doc.GetElementById("signIn");
HtmlElement passwordElement = doc.GetElementById("Passwd");
usernameElement.SetAttribute("value", "currentemailAdress@gmail.com");
loginBtnElement.InvokeMember("click");
passwordElement.SetAttribute("value", "password"); //This is the line
//loginBtnElement.InvokeMember("click");
}