HTTPUnit and JavaScript - what are the limitations?

Discussion in 'Java' started by AS, Oct 26, 2006.

  1. AS

    AS Guest

    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
     
    AS, Oct 26, 2006
    #1
    1. Advertising

  2. On Oct 26, 2:42 pm, AS <askawinska@_wytnij_to_sst.pl> wrote:
    > 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/
     
    andrewmcdonagh, Oct 28, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Koenning

    httpUnit

    Tom Koenning, Jul 22, 2003, in forum: Java
    Replies:
    1
    Views:
    4,456
    Tom Koenning
    Jul 24, 2003
  2. Neomorph
    Replies:
    0
    Views:
    1,133
    Neomorph
    Aug 14, 2003
  3. DNasmars

    HttpUnit JWebUnit for WAP apps

    DNasmars, Aug 26, 2003, in forum: Java
    Replies:
    0
    Views:
    511
    DNasmars
    Aug 26, 2003
  4. John Laury
    Replies:
    0
    Views:
    815
    John Laury
    Nov 18, 2003
  5. kalensr

    HttpUnit - JavaScript - iFrames

    kalensr, Nov 4, 2005, in forum: Java
    Replies:
    1
    Views:
    536
    Andrew Thompson
    Nov 4, 2005
Loading...

Share This Page