• 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

jwebunit/httpunit and javascript

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to test a small web application using jsp, javascript.
When executing the next testing method:
public void testFormMatriculeSubmit() {
beginAt("mandatory.jsp");
submit("action1");
assertLinkPresentWithImage("b_button_previous.gif");
}
I get an error (after the "submit in the method"):
The content type of the response is 'text/javascript': it must be 'text/html' in order to be recognized as HTML
com.meterware.httpunit.NotHTMLException: The content type of the response is 'text/javascript': it must be 'text/html' in order to be recognized as HTML
at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:916)
at com.meterware.httpunit.WebResponse.getTitle(WebResponse.java:81)
at net.sourceforge.jwebunit.HttpUnitDialog.getResponsePageTitle(Unknown Source)
at net.sourceforge.jwebunit.WebTester.assertTitleEquals(Unknown Source)
at net.sourceforge.jwebunit.WebTestCase.assertTitleEquals(Unknown Source)
at wat._test.Test_FirstWebApp.testFormMatriculeSubmit4(Unknown Source)
Doesn't httpunit normally supports javascript?
If not are there alternatives? Later on I'll have to test a more complicated web application using Struts (and javascript).
Thanks!
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, httpUnit doesn't support Javascript.
There are some unit testing frameworks available on http://www.xprogramming.com/software.htm - don't know about their usefulness, though.
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to take a look at this page also.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems as if I was wrong and httpUnit in fact supports testing JavaScript (to some extend): http://httpunit.sourceforge.net/doc/faq.html#javascript
[ April 07, 2003: Message edited by: Ilja Preuss ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this,
public void testFormMatriculeSubmit() {
beginAt("mandatory.jsp");
submit("action1");
gotoRootWindow();
assertLinkPresentWithImage("b_button_previous.gif");
}
[ June 03, 2003: Message edited by: ChienPei Wang ]
 
Vincent Depouillon
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using "gotoRootWindow();" solves my problem indeed.
Thanks ChienPei Wang!
Can you explain a little why i need to execute this command here?
Thanks!
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are two bugs submitted on JWebUnit about a similar problem. The problem is specific to JWebUnit. Try writing the same test case without JWebUnit, ony using HttpUnit. The problem seems to be with the way they are using the listner they register in the HttpUnitDialog.
I tried taking the code out that adds the listner, but it creates other problems. This was just a stopper for me and for Jameleon that I just finished writing an HttpUnit plugin for Jameleon.
I looks like they have known for at least four months about this bug and it hasn't been fixed yet. You might want to think about using just HttpUnit instead.
 
Christian Hargraves
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They believe they found a quick patch to this bug.
Try looking here
You'll need to know enough to edit the java code and rebuild the jar ( without running the unit tests because they will probably fail ).
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jwebunit has been updated and the bug is fixed !

just visit http://jwebunit.sourceforge.net
 
reply
    Bookmark Topic Watch Topic
  • New Topic