Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

HttpUnit and Ajax enabled submit buttons

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EDIT: Disregard this post; I'm probably going to move over to HtmlUnit instead, which has much better Ajax support.

To start off, I'm very new to HttpUnit and Ajax.

Ok, so I need to test an Ajax enabled submit button with HttpUnit. Here's what I'm currently doing in my HttpUnit test:



public void testNextPageButton() throws Exception
{
System.out.println("start of testNextPage");
WebResponse nextPage, nextPage2, nextPage3;
WebForm nextPageForm, nextPageForm2, nextPageForm3;

//turn off scripting for certain tests; Turn off javascript interpreting; eliminates 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



//initialize WebConversations and Responses
nextPage = webConversation.getResponse(ADDRESS);
nextPageForm = webResponse.getForms()[0];
nextPage2 = webConversation.getResponse(ADDRESS);
nextPageForm2 = webResponse.getForms()[0];
nextPage3 = webConversation.getResponse(ADDRESS);
nextPageForm3 = webResponse.getForms()[0];


System.out.println("first webResponses \n____FORM: " + form + " \nNEXTPAGE " + nextPage + " \nNEXTPAGE2 " + nextPage2 + " \nNEXTPAGE3 "
+ nextPage3);



nextPage = form.submit(form.getSubmitButtonWithID("buttonNextPage"));
nextPageForm = nextPage.getForms()[0];

System.out.println("After nextPage dif \n____FORM: " + form + " \nNEXTPAGE " + nextPage + " \nNEXTPAGE2 " + nextPage2 + " \nNEXTPAGE3 "
+ nextPage3);



nextPage2 = nextPageForm.submit(form.getSubmitButtonWithID("buttonNextPage"));

nextPageForm2 = nextPage2.getForms()[0];

System.out.println("After nxtPage2 dif \n____FORM: " + form + " \nNEXTPAGE " + nextPage + " \nNEXTPAGE2 " + nextPage2 + " \nNEXTPAGE3 "
+ nextPage3);



nextPage3 = nextPageForm2.submit(form.getSubmitButtonWithID("buttonNextPage"));
nextPageForm3 = nextPage3.getForms()[0];

System.out.println("After nxtPage3 dif \n____FORM: " + form + " \nNEXTPAGE " + nextPage + " \nNEXTPAGE2 " + nextPage2 + " \nNEXTPAGE3 "
+ nextPage3);



}

Below is the System.out.println's:

start of testNextPage
first webResponses

____FORM: com.meterware.httpunit.WebForm@f6438d

NEXTPAGE HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:40 GMT ]

NEXTPAGE2 HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:43 GMT ]

NEXTPAGE3 HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:44 GMT ]

After nextPage dif

____FORM: com.meterware.httpunit.WebForm@f6438d

NEXTPAGE HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home;jsessionid=355F23AF3DD9C39A744C783C4D00A231; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:49 GMT ]

NEXTPAGE2 HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:43 GMT ]

NEXTPAGE3 HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:44 GMT ]

After nxtPage2 dif


____FORM: com.meterware.httpunit.WebForm@f6438d

NEXTPAGE HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home;jsessionid=355F23AF3DD9C39A744C783C4D00A231; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:49 GMT ]

NEXTPAGE2 HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:54 GMT ]

NEXTPAGE3 HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:44 GMT ]

After nxtPage3 dif

____FORM: com.meterware.httpunit.WebForm@f6438d

NEXTPAGE HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home;jsessionid=355F23AF3DD9C39A744C783C4D00A231; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:49 GMT ]

NEXTPAGE2 HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:54 GMT ]

NEXTPAGE3 HttpWebResponse [url=http://localhost:8080/StrutsStarter2/Home; headers=
CONTENT-TYPE: text/html
TRANSFER-ENCODING: chunked
SERVER: Apache-Coyote/1.1
DATE: Wed, 03 Jun 2009 19:31:59 GMT ]




I'm trying to follow the submit buttons like I normally would in an httpUnit test. However, it doesn't appear to work, and the S.O.P's that I've posted is what I get during execution of the HttpUnit test. Does anyone know what I should be doing to the Ajax-enabled buttons instead of what I'm currently doing? Or, does anyone have a link to a useful resource that has information about using Ajax-enabled buttons with HttpUnit? Or even a link that has help with using Ajax with HttpUnit? Any help at all would be appreciated. Thanks.
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic