HTTPUnit and JavaScript - what are the limitations?

A

AS

Hi all,

I've just tried to test a web application with HTTPUnit but seem to
have encountered an obstacle I can't overcome.

The webpage relies strongly on JavaScript (well, which one doesn't
nowadays?), for example by calling JavaScript functions instead of
containing traditional anchors. No rocket science involved, in fact.

However, after I'd found it impossible to follow such a link with
HTTPUnit:

java.lang.RuntimeException: No such property: name at
com.meterware.httpunit.scripting.ScriptableDelegate.set(ScriptableDelegate.java:99)
at com.meterware.httpunit.FormControl$Scriptable.set(FormControl.java:391)
at
com.meterware.httpunit.TextFormControl$Scriptable.set(FormControl.java:793)
at
com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.put(JavaScript.java:275)
at
org.mozilla.javascript.ScriptableObject.putProperty(ScriptableObject.java:1476)
at org.mozilla.javascript.ScriptRuntime.setProp(ScriptRuntime.java:842)


I found a single post in HTTPUnit's mailing list stating that it's
impossible to set fields in JavaScript, only to read fields.
(http://sourceforge.net/mailarchive/forum.php?thread_id=2817744&forum_id=5833)

I must confess I can't believe it's true - I can't imagine so many
people using (and praising) HTTPUnit if it doesn't implement this basic
and crucial functionality.

Has anyone encountered a similar problem before?

Thanks for any help,


Anna Skawinska
 
A

andrewmcdonagh

Hi all,

I've just tried to test a web application with HTTPUnit but seem to
have encountered an obstacle I can't overcome.

The webpage relies strongly on JavaScript (well, which one doesn't
nowadays?), for example by calling JavaScript functions instead of
containing traditional anchors. No rocket science involved, in fact.

However, after I'd found it impossible to follow such a link with
HTTPUnit:

java.lang.RuntimeException: No such property: name at
com.meterware.httpunit.scripting.ScriptableDelegate.set(ScriptableDelegate.java:99)
at com.meterware.httpunit.FormControl$Scriptable.set(FormControl.java:391)
at
com.meterware.httpunit.TextFormControl$Scriptable.set(FormControl.java:793)
at
com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.put(JavaScript.java:275)
at
org.mozilla.javascript.ScriptableObject.putProperty(ScriptableObject.java:1476)
at org.mozilla.javascript.ScriptRuntime.setProp(ScriptRuntime.java:842)

I found a single post in HTTPUnit's mailing list stating that it's
impossible to set fields in JavaScript, only to read fields.
(http://sourceforge.net/mailarchive/forum.php?thread_id=2817744&forum_...)

I must confess I can't believe it's true - I can't imagine so many
people using (and praising) HTTPUnit if it doesn't implement this basic
and crucial functionality.

Has anyone encountered a similar problem before?

Thanks for any help,

Anna Skawinska

Hi Anna,

Personally, I gave up with HTTPUnit in favour of the following.....


1) JUnit for testing the Java at the unit test level.
By this I mean, writing JUnit tests for each class within the project.
I didn't Unit test the View (HTTP) part of my application, just the
Model and Presenter logic.

2) I use Selenium for Acceptance tests (aka Integration/system tests),
Selenium drives web apps directly via the browser, just like a human
would use them, but obviously its automated. These tests cover the
View part of the application that the unit tests do not.


Regards

Andrew

http://www.openqa.org/selenium/
 

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top