colin froggatt - 2003-02-26

Hi, I've just started using HttpUnit and so far I've been very impressed.  However I am having a problem getting content back for a frameset. 

The page flow is as follows:

    1/ login page - submit form with login details
    2a/ search page - display search page after successful login
    2b/ login page - display logon failed error message
   
The frameset has a menu at the top and bottom and then the page content sits in the middle.

Getting the content text for the login page works fine.  After submitting the login form and requesting the search page, getting the text for the content frame returns the original login page text and not the search page text.

I'm sure that the test is following the links because I've watched with an Http sniffer (Httplook) and the correct content is returned when the frameset is updated.  If I get the content of the updated frameset, it is correct, but getting the updated frame content is incorrect.

I have search the lists and google to try and find something out about this but with no luck.  I have also updated the neckohtml jar and tried with JTidy, but again, no change.  The site works fine in the browsers.

Any help, pointers or guidence with this problem would be much appreciated.

I am using httpunit 1.5.1 with neckohtml 0.7.3 on jdk 1.4.1_01.  The pages are being served by Apache 1.3.x.

The frameset is listing 1, the test case in listing 2.

Listing 1:
------ 1 START -----

<head>
<title>Interlink Express - about us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<frameset rows="95,560*" frameborder="NO" border="0" framespacing="0" cols="*">
   <frame name="nav" scrolling="NO" noresize src="../html/menu/track_it_track.htm" marginheight="10" marginwidth="0">
   <frameset rows="*,48" frameborder="NO" border="0" framespacing="0" cols="*">
     <frame name="content" src="../trackingApp/trackingServlet?business=interlink&geopostAction=search" marginwidth="11" marginheight="8">
     <frame name="quick_track" scrolling="NO" noresize src="../html/quicktrack/quicktrack.htm" marginwidth="0" marginheight="0">
   </frameset>
</frameset>
<noframes>
<body bgcolor="#FFFFFF">
</body>
</noframes>
</html>
------ 1 END -----

Listing 2
------ 2 START -----
... // init stuff
/**
* Verifies that submitting the login form with valid username and password results in success
**/
public void testIeSuccessfulLogin() throws Exception
{
    WebResponse top = conversation.getResponse(IE_LOGON_URL);
    top = conversation.getFrameContents("content"); 

    top = doIeLogin(conversation, top, "test", "testpwd");

    Logger.debug(CLASS, "FRAMESET TEXT: " + top.getText());

    WebResponse content = conversation.getFrameContents("content");

    Logger.debug(CLASS, "CONTENT TEXT: " + content.getText()); 

    assertIeSearchPage(conversation, content, 6);
}

private WebResponse doIeLogin(WebConversation conversation, WebResponse response, String userName, String password)
    throws SAXException, MalformedURLException, IOException
{
    WebRequest request;
    WebForm forms[] = response.getForms();

    assertEquals( 1, forms.length  );
    assertNotNull("missing form name: GetLoginInfo", response.getFormWithName("GetLoginInfo"));
    assertEquals( 7, response.getFormWithName("GetLoginInfo").getParameterNames().length );

    WebForm loginForm = response.getFormWithName("GetLoginInfo");
    request = loginForm.getRequest();

    if (userName != null)
    {
        request.setParameter( "userId", userName );
    }

    if (password != null)
    {
        request.setParameter( "password", password );
    }

    return conversation.getResponse( request );
}

private void assertIeSearchPage(WebConversation conversation, WebResponse response, int numFields)
    throws MalformedURLException, IOException, SAXException
{
    ..... // test that we got the page
}

------2 END -----