form is not supmitted

  • Hi all and greetings from Munich/Germany!

    I am facing an anoying problem here. I wrote a small HttpUnit class to test
    my website but the submit() has no effect at all. I never reach the
    Welcome page; currentPage is always the login page.
    Does anybody has a hint for me?
    I am running out of ideas... :-/

    My code:
    public void testMailLogin() throws Exception {
          try {
                  WebConversation conversation = new WebConversation();
                WebRequest  request = new GetMethodWebRequest(URL);
                WebResponse response = conversation.getResponse(request);
                assertNotNull("No response from URL '" + URL + "'.", response);
                System.out.print("Fetching password login form .........");
             WebForm loginForm = response.getFormWithName("login_Password");
                assertNotNull("No form found with ID 'login_Password'", loginForm);

            // Fill out auth data and submit login form
                loginForm.setParameter("usr_name", "admin");
                loginForm.setParameter("usr_password", "secret");

                System.out.print("Test presence of login button ........");
                SubmitButton sb = loginForm.getSubmitButton("login");
                assertNotNull("No button found with ID 'login'", sb);
                response = loginForm.submit(sb);
                assertNotNull("No response after submit of login button", response);
                WebResponse selectUserPage = conversation.getCurrentPage();
                assertEquals(selectUserPage.getText().indexOf("Welcome") != -1, true);
        catch (Exception e) {
            System.err.println("Exception: " + e);
      } // testMailLogin()


    my page:

    <form action="?" method="post" name="login_Password" target="_self" autocomplete="off" onsubmit="return isSingleClick()">
    <input maxlength="255" value="" name="usr_name" type="text" class="textfield " /><br/>
    My password<br/>
    <input maxlength="32" value="" class="textfield " type="password" name="usr_password" /><br/>



    • zeyad

      Hello sire,
      Your condition is not correct assertEquals(selectUserPage.getText().indexOf("Welcome") != -1, true); because the assertEquals() it can not make assert for  boolean result with character excepted value (true), So I suggest to check your page title in welcome page instead of using this comparison

      With regards

      • Hi and thank you for the reply,

        thx for the hint but I still have the problem that
        the login-Form is not submitted.
        selectUserPage.getText() prints always the code of the login
        page, not the expected welcome page :-(


    • No idea, anyone?

    • Jeff

      Check this and try something similar:

      • *antk43* Thanks 4 the hint!