Using HTTPUnit for web automation in Java 1.4 project (struts framework)

Like the title says I'm trying to perform some web automation (i.e. some of the data captured by my web app needs to be entered to an exisiting online tool and have the form submitted. I gather httpunit is a possible solution for this.

So what I did was add the httpunit.jar, and other jars that came with the httpunit package, to my buildpath.

Then I added the following test method in one of my action classes:

privatevoid postWB()throws MalformedURLException, IOException, SAXException{

WebConversation wc =new WebConversation();

// Obtain the main page on the meterware web site

WebRequest request =new GetMethodWebRequest("http://www.meterware.com" );

WebResponse response = wc.getResponse( request );

// find the link which contains the string "HttpUnit" and click it

WebLink httpunitLink = response.getFirstMatchingLink( WebLink.MATCH_CONTAINED_TEXT,"HttpUnit" );

response = httpunitLink.click();

// print out the number of links on the HttpUnit main page

System.out.println("The HttpUnit main page contains " + response.getLinks().length +" links" );

}

however when I have it in there the jsp fails to render, regardless of whether the method is actually called, and when I take the code out it works find. I can't see anything in the console that indicates an error I just get a error 500.

Any ideas?

Is http unit the best way to be doing this? Keep in mind all I'm basically trying to do is the equivilent of submitting a form on a page (like automating a google search just from my java app)

[2028 byte] By [Piersa] at [2007-11-27 10:59:32]
# 1

anybody used this API at all?

I'm completely lost.

Piersa at 2007-7-29 12:23:45 > top of Java-index,Java Essentials,Java Programming...