Reputation: 11
I'm new at Visual Basics and I'm trying to fill the forms of the following website:
I tried using this line of code:
WebBrowser1.Document.GetElementById("nome").SetAttribute("Value", "Test")
However, whenever I try I got the following error:
A first chance exception of type 'System.NullReferenceException' occurred.
I would appreciate if someone could help me to accomplish this, it would save me a lot of time if I could automate this task.
Thank you in advance, Daniel.
Upvotes: 1
Views: 6391
Reputation: 11
WebBrowser1.Document.GetElementById("nome").InnerText = Test
That will select the input named "nome" and fill it with the text "Test"
Hope this helps.
Upvotes: 1
Reputation: 26454
You need to be using a combination of WebClient and HtmlAgilityPack. See these examples:
Upvotes: 0
Reputation: 5269
According to Microsoft documentation, the SetAttribute function your are using is case sensitive.
You'll need to replace "Value" for "value".
WebBrowser1.Document.GetElementById("nome").SetAttribute("value", "Test")
However, the kind of error message you are getting seems to occur before the call to the SetAttribute function. Go in debug mode and make sure that every objects used before the SetAttribute function are not null.
Upvotes: 0