• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trouble using HttpUnit with Struts 2 tabbedpanel

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks.


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.
HttpUnitOptions.setScriptingEnabled(false);

//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.
System.out.println(buttons[1]);//Edit
System.out.println(buttons[2]);//Delete
System.out.println(buttons[3]);//<<
System.out.println(buttons[4]);//<
System.out.println(buttons[5]);//Go
System.out.println(buttons[6]);//>
System.out.println(buttons[7]);//>>


//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).
System.out.println(parameterList[3]);
System.out.println(parameterList[4]);

}

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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HtmlUnit is far more better
 
Brandon Headrick
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Do not threaten THIS beaver! Not even with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic