#445 NullPointerException from getFormWithID


Here are the relevant lines of code from my .java files:

31 WebResponse resp = wc.getResponse(URL);
32 WebResponse content = wc.getFrameContents("content");
33 WebForm form = content.getForms()[0];
34 System.out.println("***** \"" + form.getID() + "\"");
35 form = content.getFormWithID("loginForm");
36 System.out.println(form.getID());

and here is the output in the terminal:

***** "loginForm"
at RealEdController.login(RealEdController.java:36)


  • Warwick Hunter

    Warwick Hunter - 2011-04-12

    Would you provide a little more context please? Your stack trace doesn't show any httpunit code in the trace. If you could post a junit test case to reproduce the problem that would be a big help.

  • Warwick Hunter

    Warwick Hunter - 2011-04-12

    Here's my attempt at a reproducer. It doesn't show the problem. Can you modify it to reproduce the problem?

    /** Bug 3152752 from the sourceforge area */
    public void testFrameNPE() throws Exception {
    defineWebPage( "Text", "This is a trivial page" );
    defineWebPage( "Form", "This is a page with a simple form: " +
    "<form id='loginForm' action=submit><input type=submit></form>");
    defineResource( "Frames.html",
    "<html><head><frameset>" +
    " <frame name='content' src='Form.html'>" +
    " <frame name='text' src='Text.html'>" +
    "</frameset></html>" );

    WebConversation wc = new WebConversation();
    WebResponse resp = wc.getResponse(getHostPath() + "/Frames.html");
    WebResponse content = wc.getFrameContents("content");
    assertTrue(content.getForms().length > 0);
    WebForm form = content.getForms()[0];
    assertEquals("loginForm", form.getID());
    form = content.getFormWithID("loginForm");
    assertEquals("loginForm", form.getID());

  • Wolfgang Fahl

    Wolfgang Fahl - 2012-09-13

    Dear httpunit user!

    Thank you for your bug report. We appreciate the time and effort you are putting into this.

    Please supply a testcase with the expected result for the bug report that you are asking a solution for and we'll look into implementing it. For a start you might want to get the trunk version from the subversion repository (see https://sourceforge.net/svn/?group_id=6550\)
    and have a look at the source code of some of the more than 700 JUnit based testcase in there.

    If you do not use or have subversion tool you can still directly browse our test cases via:
    Looking into one or more of the Junit Java source files
    should give you a clue on what a proper testcase for httpunit looks like, often you will probably only have to "clone" an existing testcase and modify it slightly to your needs.

    When you are ready you might want to attach the testcase (and if you already have started implementing a solution for it it also the actual code) to the patch section of the sourceforge.net tracker for patches of the httpunit project at

    The main communication about further details of the development is via the httpunit developer mailinglist. You are most welcome to sign up via

    The httpunit developer team

    (Russell, Wolfgang, Mark, Patrick and Tim as of 2008-04)

  • Wolfgang Fahl

    Wolfgang Fahl - 2012-09-13

    Dear kinetic87

    Thank you for your bug report.
    Please supply a test case as per the FAX of the httpunit developer mailing list. At least we'd need some small html snippet that shows when the form id is set to null when it shouldn't be null.


  • Wolfgang Fahl

    Wolfgang Fahl - 2012-09-13
    • assigned_to: nobody --> wolfgang_fahl

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks