• Post Reply Bookmark Topic Watch Topic
  • New Topic

Web form interaction and submission via Java (HttpUnit).  RSS feed

 
Sam Saint-Pettersen
Greenhorn
Posts: 7
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I am trying to write some Java code to interact with a web form and click the submission button to submit the form transparently in the background.
I have been trying to accomplish this task using HttpUnit, which is a library with probably more features than I require.

Anyway I have figured out using the WebConversation, WebResponse and HTMLElement classes,
I can retrieve each element in the form, but HttpUtility seems to use its Button class and a method from that to
execute a button action. I tried casting an HTMLElement to a Button, but it didn't work.

Anyway here is my code:

Here is the web form document I am using for testing this on localhost:


I would appreciate any feedback on how to do this from those who have used HttpUnit or if you think its more applicable with any other library
that can do what I want to here.

Thank you in advance.

Kind regards,

Sam.


 
Tim Moores
Saloon Keeper
Posts: 4034
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably not a helpful reply, but I prefer HtmlUnit over HttpUnit - it has a higher-level API. On top of HtmlUnit you could even go for jWebUnit - still higher-level (meaning fewer method calls to achieve something).
 
Sam Saint-Pettersen
Greenhorn
Posts: 7
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers. I'll probably go straight for jWebUnit, as I want to keep it as simple for me as possible. Thanks again.
 
Sam Saint-Pettersen
Greenhorn
Posts: 7
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this code. I added all the associated libraries, but I get an error.





It says I haven't but I have defined the testing engine. Any ideas? Thanks.
 
Tim Moores
Saloon Keeper
Posts: 4034
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh dear, no I haven't. Is HtmlUnit in the classpath? I guess it is, going by your comment.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!