Part of my WPF application has two text boxes for username and password. With a click of a button, the program should log the user into a website. The issue is that GetElementById is throwing up an error:
'object' does not contain a definition for 'GetElementById' and no extension method 'GetElementById' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
The code in question is this:
private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
{
webBrowser1.Document.GetElementById("AccountBarLogin").InvokeMember("click");
webBrowser1.Document.GetElementById("QuickLoginEmail").SetAttribute("value", textBox1.Text);
webBrowser1.Document.GetElementById("QuickLoginPassword").SetAttribute("value", textBox2.Text);
webBrowser1.Document.GetElementById("QuickLoginSubmit").InvokeMember("click");
}
I have added a reference to System.Windows.Forms, as well as to MSHTML. What exactly needs to be referenced to prevent the GetElementByID throwing up this error?
Saw this: System.Windows.Forms.HtmlDocument does not contain a definition for GetElementByID but in this case it does not seem to be a typo.