I have a WebBrowser control where I want to edit a field in the HTML and then submit a form. Let’s say that the field is called txtUname and that the submit button is called submit in form form1. How can I do this?
I’m currently thinking of using something like this, but I haven’t tested it:
//Change value
webBrowser1.Document.getElementbyId("txtUname").setAttribute("value","this is my value");
//Submit form
webBrowser1.Document.Forms("form1").invokeMember("submit");
In addition, does this work for any type of field?
Also, is it possible to do something similar inside a WebClient?
It would be much more difficult to do with a WebClient, if even possible.
Why are you trying to do it though? Because if it is to test the web pages then you are better off with Selenium or WaitN.
They will allow you to do something like this in a unit test:
That example is from the WaitN homepage…