File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Trouble using HttpUnit with Struts 2 tabbedpanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Trouble using HttpUnit with Struts 2 tabbedpanel" Watch "Trouble using HttpUnit with Struts 2 tabbedpanel" New topic

Trouble using HttpUnit with Struts 2 tabbedpanel

Brandon Headrick

Joined: Jun 03, 2009
Posts: 4
So, I'm trying to use HttpUnit to test a webpage. However, I'm not sure how to follow tabbedpanel(s) from Struts 2. I tried treating it like a normal webpage, in the code below; however, the submit() method for the button I'm trying to select, "New," either doesn't appear to work or, what I suspect is more likely, it just pushes the button and doesn't know to go anywhere because of the tabbedpanel. I'm new to Struts 2 and HttpUnit, so any help would be useful. I've commented heavily, and to some degree, unnecessarily, so I hope it's enough to get some help.


Here's the code snippet.

public void testNewOrder() throws Exception

//turn off scripting for certain tests; Turn off javascript interpreting; required because of depricated dojo conflicts.

//webConv represents browser (emulates browser behavior)
WebConversation webConversation = new WebConversation();
//webResp represents page (actual response from website).
//Pass address to getResponse method from browser, put that into the page
// instance
WebResponse webResponse = webConversation.getResponse(ADDRESS);

WebForm form = webResponse.getForms()[0]; //select first form in page

//create a submitButton Array populated with the buttons from the form
SubmitButton[] buttons = form.getSubmitButtons();

System.out.println(buttons[0]);//New //just s.o.p code to remind me which buttons are which.

//follow the "New" button.
WebResponse newOrderPage = form.submit(buttons[0]);

//populate this form with the forms on the "New" page
WebForm newOrderPageForm = newOrderPage.getForms()[0];

String[] parameterList = newOrderPageForm.getParameterNames();

System.out.println(parameterList[0]); //This s.o.p. tells me that the parameters of the new page, which should contain 6 variables,
System.out.println(parameterList[1]); //that correspond to different textfields, are not on the page, instead it pulls the parameters
System.out.println(parameterList[2]); //from the "home" page (which has 5 parameters).


EDIT: I now believe it to be more of an Ajax issue than a tabbedpanel issue. I'm going to post a different problem, however, it is still slightly related, on the testing board if you think you can still help me.
Ahmed Ashour

Joined: Jun 03, 2009
Posts: 2
HtmlUnit is far more better
Brandon Headrick

Joined: Jun 03, 2009
Posts: 4
Maybe so, I don't really know. However, I have to use HttpUnit for my job; those are my instructions, and there may be a reason that I have to use HttpUnit in their design.

EDIT: I've talked to my boss; I may be changing over the work to HtmlUnit instead. Thanks for the help.
I agree. Here's the link:
subject: Trouble using HttpUnit with Struts 2 tabbedpanel
It's not a secret anymore!