• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Automating HTML form input

 
Norm Radder
Ranch Hand
Posts: 1011
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using a web site that has a form with an input field and a submit button. I have many values that I would like to input to this site using this form and find entering them one at a time very tedious.
I would like to automate the input to the HTML form as much as possible. So far I have three programming solutions:

1) Proxy server - this program intercepts the incoming html and changes it to preload the next value to be submitted. After the page has loaded in the browser with the field in the form filled in, I press the submit button and wait for the next preloaded page to arrive. I continue pressing submit after each preload until all the data has been submitted. I have this code mostly working.

2) Robot inputter - After loading the form into the browser, this program would be initialized to know where the input field is and where the submit button is. On pressing its DoIt button, it would get the next line to be submitted, write it to the input field and press the form's submit button. I would wait until the form is loaded then press the Robot program's DoIt button to do it again. This would require the user to watch and wait until the HTML page has been loaded and is ready to receive input. Is the Java Robot class capable of doing this?

3) Automatic "browser" - This program would do all the browser functions, fill in the form and do the submit without any user interventions. The HTML engine in this program would need to be able to handle JavaScript etc. Is this possible?

Are there other ways of doing this?


Thanks,

Norm
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you take the browser out of the picture entirely? Using URL and HttpURLConnection you can post anything you like with just Java.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest the HttpClient library for imitating a browser instead of Java Robot. Much easier than programming from scratch with HttpURLConnection, particularly if the service you have to talk to uses cookies to track users.

HttpClient - an Apache Software Foundation open source toolkit is well supported.

What is the source of data to fill in the form?

Bill
 
Norm Radder
Ranch Hand
Posts: 1011
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the responses.

The HTML page I'm working with has several forms on it, maps and a good bit of Javascript. It would be a very difficult task to correctly format the data for the POST action generated by pressing one of the submit buttons. I think that a browser is needed to do that. I was hoping that the HTMLDocument would do some of the work, but I haven't found any examples.

Norm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic