This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Testing and the fly likes Better JavaScript support than HtmlUnit? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Better JavaScript support than HtmlUnit?" Watch "Better JavaScript support than HtmlUnit?" New topic
Author

Better JavaScript support than HtmlUnit?

Scott H Ferguson
Greenhorn

Joined: Feb 15, 2006
Posts: 1
I have been developing some in-house WebApp testing tools using HtmlUnit. In a couple of cases I was able to tweek the HtmlUnit source code to support the odd bit of JavaScript that is not currently supported in version 1.7.

As the pace of development of out webapp has increased I am starting to run into more instances where javascript is not supported (ie, javascript urls). I am afraid that I can not keep up and that the HtmlUnit will not have a fully compliant product in the near future.

Are there any free or commercially available packages that work by emulating the browser, like HtmlUnit, but FULLY implement javascript functionality?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
I'm afraid all three main tools (HtmlUnit, HttpUnit, jWebUnit) use the same Rhino JavaScript engine for JavaScript support. What you could try is a tool that uses the real browser, such as Watir (Ruby/Windows), Pamie (Python/Windows), or Selenium (multi-language, multi-platform, but possibly a bit tricky to set up and integrate into your development environment).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Yes, even I have faced this problem while testing my Ajax stuff with HtmlUnit/HTTPUnit. Any workaround for that?

- Manish
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
One possible partial work-around is to separate the testing of the fundamental request/response data versus testing the rendered result itself. For example, if you are using Struts then MockStrutsTestCase can be used to see if the data about to be send to the JSP page and the selected forwarding is what you expect. That tells you if everything prior to the final rendering is at least correct.

For Javascript-specific testing, there are I think three derivations of JUnit out there, but really they are only helpful for letting you test a Javascript library, not so much a specific page. I haven't seen anything that combined HttpUnit-like testing of the rendered result with Javascript either.


Reid - SCJP2 (April 2002)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Better JavaScript support than HtmlUnit?
 
Similar Threads
httpunit and java script
can HttpUnit test pop-up window ?
Webapp testing toolkits
httpunit javascript.EcmaError: createElement
Problem with Radio buttons