Need help with displaying read html in web browswer control VB.Net

hi,

I have a VB.Net app which "reads" in html pages from a web server using winhttp. The purpose is for the app to "fill in" data fields on the page, then send it back to the web server, as if a user had been entering the data in his web browser. It's part of a data input automation project.

I'd like, for my own testing, to show the pages I am accessing. So I added a webBrowser control to my main form, I have the html sent by the server (as a response string from my HttpReq.Send call)... but I don't know how to feed that string of html to the webBrowser control. Should be easy, but I just don't get it.

So I have some questions:
- am I using the right means to render the html ?
- if yes, how can I "feed" the html text to the webBrowser control ?
- in any case, how can I render that html on my VB form in an easy way ?

Thanks for any help on this.

BalexH

[951 byte] By [BalexH] at [2007-12-28]
# 1

The webbrowser has a text property and a parameterless constructor. So you should be able to create a new instance of the control and set the text property with the string you grabbed from the page. Then, at a guess you will probably want to refresh the page.

As for reading the data and then actually populating the fields, I'm not entirely sure what you need to do - I mean, how are you going to populate the fields on the page with the page if the user hasn't entered the data? And it also sounds like you don't want to be saving the file and sending the page back, rather, you want to post some data to a webservice that will handle it...

weirdbeardmt at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Thanks for your reply. I'll try out that text property.

The purpose of my app IS exactly to simulate the entry by the user, i.e. I not only get the page but search within the html for a given form tag (using its name) to retrieve the method (GET/POST) and action (URL) which that form uses, I look for a set of given input tags checking that they are there and that they are of the "input" tag type, then I construct and send, based on all this info, the same response to the web server as if the user himself had filled the input fields with the values... So no, I'm not posting the data to a web service, but just to the web server, which will think that the user has filled the fields and click on whatever submit button there was on the page.

Because all this is done pretty much "flying in the dark" by code, I thought I'd add the rendering of the current html page, so that I'd see when testing where I am, as the process is recurring. I have to call many pages to input all the data. And of course some pages are based on data entered on previous pages, therefore it'd be useful to not only do the work, but to have an optical rendering of the job being done...

BalexH

BalexH at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
Hmm, I understand. Sounds a little awkward to me, but I'm sure you have your reasons for this design.

Are you OK with searching the HTML to find the tags etc etc? If you're looking for input tags, e.,g, <input type="text" then you might consider using a regular expression and a match collection, as that will put all matching in to a manageable collection... though of course you'll need to grab the name attribute as well, so I guess you'll be looking for the closing >.

Good luck with this!

weirdbeardmt at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...