6 Replies Latest reply on Sep 3, 2008 12:12 PM by Stan Silvert

    Beta3 clicking on command Button is broken

    Tim Evers Master

      I've just downloaded and build the latest version of JSFUnit. And now I'm getting an error when clicking on a command button. I end up with the page:

      HtmlPage(javascript:'')@742012
      


      Here are the relevant snippets of my test and xhtml

      The xhtml (note I removed our custom tags to see if they were the problem, but....I'm still having the issue.
      <?xml version="1.0" encoding="UTF-8"?>
      <ui:composition
       xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:gekko="http://gekkoTagLibs.com"
       template="/layout/template.xhtml">
      
       <ui:define name="body">
      
       <ui:insert name="formheading" />
      
       <gekko:summaryPanel id="summaryPanel">
       <gekko:summaryData
       id="userData"
       label="User"
       value="#{UserMaintenanceDataBean.userFullName}" />
       <gekko:summaryData
       id="loginData"
       label="Login ID"
       value="#{UserMaintenanceController.user.loginId}" />
       </gekko:summaryPanel>
      
       <gekko:tabGroup id="tabGroup">
       <!--<gekko:tabButton id="detailsTab" action="#{UserMaintenanceController.gotoUserDetailsTab()}" value="Details" disabled="#{UserMaintenanceController.isTabDisabled()}"/>
       <gekko:tabButton id="rolesTab" action="#{UserMaintenanceController.gotoUserRolesTab()}" value="Roles" disabled="#{UserMaintenanceController.isTabDisabled()}" />
       <gekko:tabButton id="workgroupsTab" action="#{UserMaintenanceController.gotoUserWorkgroupsTab()}" value="Workgroups" disabled="#{UserMaintenanceController.isTabDisabled()}" />
       <gekko:tabButton id="districtsTab" action="#{UserMaintenanceController.gotoUserDistrictsTab()}" value="Districts" disabled="#{UserMaintenanceController.isTabDisabled()}" />-->
      
       <h:commandButton
       id="detailsTab"
       action="#{UserMaintenanceController.gotoUserDetailsTab()}"
       value="Details" />
       <h:commandButton
       id="rolesTab"
       action="#{UserMaintenanceController.gotoUserRolesTab()}"
       value="Roles" />
       <h:commandButton
       id="workgroupsTab"
       action="#{UserMaintenanceController.gotoUserWorkgroupsTab()}"
       value="Workgroups" />
       <h:commandButton
       id="districtsTab"
       action="#{UserMaintenanceController.gotoUserDistrictsTab()}"
       value="Districts" />
       </gekko:tabGroup>
      
       <ui:insert name="formcontents" />
      
       <h:panelGroup
       layout="block"
       styleClass="mainButtonGroup">
       <gekko:commandButton
       id="userCancelButton"
       buttonType="submit"
       action="#{UserMaintenanceController.doCancel()}"
       value="CANCEL"
       rendered="#{false}" />
       <gekko:commandButton
       id="userSaveButton"
       buttonType="submit"
       action="#{UserMaintenanceController.doSave()}"
       value="SAVE"
       rendered="#{UserMaintenanceController.canSave()}" />
       <gekko:commandButton
       id="userSaveReturnButton"
       buttonType="submit"
       action="#{UserMaintenanceController.doSaveReturn()}"
       value="SAVE/RETURN"
       rendered="#{UserMaintenanceController.canSaveReturn()}" />
       <gekko:commandButton
       id="userEditButton"
       buttonType="submit"
       action="#{UserMaintenanceController.doEdit()}"
       value="EDIT"
       rendered="#{UserMaintenanceController.canEdit()}" />
       </h:panelGroup>
      
       </ui:define>
      </ui:composition>
      


      Now the test.... part that fails.
      log.debug("Click search for users");
      searchPage.clickSearch();
      assertTrue("No results returned from search.", searchPage.getNumberOfResults() > 0);
      searchPage.clickMaintainUserLink(0);
      maintenancepage = getPageDriver(UserDetailsMaintenancePageDriver.class);
      log.debug("Assert we have gone to the maintenance page.");
      assertTrue("User Maintenance (view mode) page was not displayed.", maintenancepage.isDisplayed());
      
      maintenancepage.clickEdit();
      log.debug("Change to edit mode.");
      assertTrue("User Maintenance page (edit mode) was not displayed.", maintenancepage.isDisplayed());
      
      String newName = "UserTestFirstname:" + DateFormatUtils.formatDate(dateSvc.getCurrentDateTime(), DateFormatUtils.ISO_FULL_DATETIME_FORMAT);
      maintenancepage.setAccountLocked(true);
      maintenancepage.setGivenName(newName);
       maintenancepage.setSurname("UserMaintenanceTestSurname");
      maintenancepage.setPosition("UserMaintenanceTestPosition");
      maintenancepage.clickSave();
      
      templatepage.clickRolesTab();
      


      Everything is fine up until that last line. The page content is correct and everything is going well. When that last line is executed any further attempts to do anything fail because my HtmlPage is corrupt.

      Here is the contents of the clickRolesTab() method:
      public void clickRolesTab() {
       click("rolesTab");
      }
      


      Which delegates to.... (Yes I've abstracted all the other devs from the api :P)
      public void click(String id) {
       try {
       testContext.getClient().click(id);
       validateNoErrorsFound();
       } catch (IOException e) {
       ExceptionUtils.createLogged(IllegalStateException.class, log,
       "Error when clicking on component with id: " + id, e);
       }
      }
      


      testContext of course is this:
      public class GekkoJSFTestContext {
      
       private JSFSession session;
       private JSFClientSession client;
       private JSFServerSession server;
      
       public JSFSession getSession() {
       return session;
       }
       public void setSession(JSFSession session) {
       this.session = session;
       client = this.session.getJSFClientSession();
       server = this.session.getJSFServerSession();
       }
       public JSFClientSession getClient() {
       return client;
       }
       public void setClient(JSFClientSession client) {
       this.client = client;
       }
       public JSFServerSession getServer() {
       return server;
       }
       public void setServer(JSFServerSession server) {
       this.server = server;
       }
      
      }
      


      This seems to be a bug that we had a long time ago and it has come back again. Strangely enough this doesn't happen on "all" my command buttons. So, I'm very confused! I'd like to not have to go back to beta 2 if possible :)

      Thanks for any tips/help anyone can give.

      On a side note though, JSFUnit is really coming along! Nice job!

        • 1. Re: Beta3 clicking on command Button is broken
          Stan Silvert Master

          So I guess the problem is in clickSave()? What does the HTML look like before and after that?

          You can dump the HTML with JSFClientSession.getPageAsText().

          Stan

          • 2. Re: Beta3 clicking on command Button is broken
            Tim Evers Master

            Ok.... I'm going to email you the full html cause its rather large :P but....
            I'll give snippets here for the benefit of the post for other people who may have the same problem :)

            So, before the clickSave() method the html is this.

            <?xml version="1.0" encoding="UTF-8"?>
            <html xmlns="http://www.w3.org/1999/xhtml">
             <head>
             ...(bunch of js stuff)
             </head>
             <body class="workarea">
             ...(bunch of boring html)
             </td>
             <td id="menuTabCell" valign="top" align="left" width="30">
             <input id="MasterPageForm:sideMenuState" type="hidden" name="MasterPageForm:sideMenuState" value="true"/>
             <img id="MasterPageForm:sideMenuTab" src="/gekko-tje/images/menu_tab.jpg" onclick="toggleSideMenuDisplay()" style="cursor:pointer"/>
             </td>
             <td style="margin-left: 3em;" valign="top">
             <div class="FormViewport">
             <dl id="MasterPageForm:j_id49" class="rich-messages errorPanel messageText" style="display: none; null">
             <dt>
             <span class="rich-messages-label">
             </span>
             </dt>
             </dl>
             <dl id="MasterPageForm:j_id52" class="rich-messages infoPanel messageText" style="display: none; null">
             <dt>
             <span class="rich-messages-label">
             </span>
             </dt>
             </dl>
             <dl id="MasterPageForm:j_id54" class="rich-messages warnPanel messageText" style="display: none; null">
             <dt>
             <span class="rich-messages-label">
             </span>
             </dt>
             </dl>
             <h1>
             User Details
             </h1>
             <div id="MasterPageForm:summaryPanel" class="summaryBox">
             <span class="summaryLabel rightAlign">
             User:
             </span>
             <span class="summaryText rightAlign">
             UserMaintenanceTestSurname, UserTestFirstname:2008-09-01 09:21:01.659
             </span>
             <span class="summaryLabel rightAlign">
             Login ID:
             </span>
             <span class="summaryText rightAlign">
             Known User
             </span>
             </div>
             <div class="gekkoTabGroup">
             <input id="MasterPageForm:detailsTab" type="submit" name="MasterPageForm:detailsTab" value="Details"/>
             <input id="MasterPageForm:rolesTab" type="submit" name="MasterPageForm:rolesTab" value="Roles"/>
             <input id="MasterPageForm:workgroupsTab" type="submit" name="MasterPageForm:workgroupsTab" value="Workgroups"/>
             <input id="MasterPageForm:districtsTab" type="submit" name="MasterPageForm:districtsTab" value="Districts"/>
             </div>
             <div id="MasterPageForm:detailsFormPanel" class="panelbox">
             <table id="MasterPageForm:mainGrid" class="formTable" width="100%">
             <tbody>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:locked" class="FormLabel ">
             Account locked:
             </label>
             <input id="MasterPageForm:locked" type="checkbox" name="MasterPageForm:locked" checked="checked" class="checkbox" value="on"/>
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:login" class="FormLabel ">
             Login ID:
             <span class="required">
             *
             </span>
             </label>
             <input id="MasterPageForm:login" type="text" name="MasterPageForm:login" value="Known User" class="FormInputText"/>
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:title" class="FormLabel ">
             Title:
             <span class="required">
             *
             </span>
             </label>
             <select id="MasterPageForm:title" name="MasterPageForm:title" class="GekkoSelectOneMenu" size="1">
             <option value="org.jboss.seam.ui.NoSelectionConverter.noSelectionValue">
             Please Select...
             </option>
             ...(a bunch of options)
             <option value="1" selected="selected">
             system
             </option>
             </select>
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:lastname" class="FormLabel ">
             Surname:
             <span class="required">
             *
             </span>
             </label>
             <input id="MasterPageForm:lastname" type="text" name="MasterPageForm:lastname" value="UserMaintenanceTestSurname" class="FormInputText"/>
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:firstname" class="FormLabel ">
             Given name:
             <span class="required">
             *
             </span>
             </label>
             <input id="MasterPageForm:firstname" type="text" name="MasterPageForm:firstname" value="UserTestFirstname:2008-09-01 12:42:08.910" class="FormInputText"/>
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:district" class="FormLabel ">
             Default District:
             <span class="required">
             *
             </span>
             </label>
             <select id="MasterPageForm:district" name="MasterPageForm:district" class="GekkoSelectOneMenu" size="1">
             ...(a bunch of options)
             <option value="1" selected="selected">
             Brisbane Corporate Headquarters
             </option>
             <option value="64">
             CertTestOffice
             </option>
             <option value="65">
             DefaultDistrictOffice
             </option>
             <option value="62">
             QCertTestOffice
             </option>
             <option value="2">
             Rockhampton
             </option>
             <option value="3">
             test data loader loaded
             </option>
             </select>
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:location" class="FormLabel ">
             Location:
             <span class="required">
             *
             </span>
             </label>
             <select id="MasterPageForm:location" name="MasterPageForm:location" class="GekkoSelectOneMenu" size="1">
             <option value="org.jboss.seam.ui.NoSelectionConverter.noSelectionValue">
             Please Select...
             </option>
             <option value="2">
             Head Office
             </option>
             <option value="1" selected="selected">
             Headquarters
             </option>
             <option value="4">
             Ipswich
             </option>
             <option value="5">
             Rockhampton
             </option>
             <option value="3">
             Townsville
             </option>
             </select>
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:position" class="FormLabel ">
             Position:
             </label>
             <input id="MasterPageForm:position" type="text" name="MasterPageForm:position" value="UserMaintenanceTestPosition" class="FormInputText"/>
             </span>
             </td>
             </tr>
             </tbody>
             </table>
             </div>
             <div class="mainButtonGroup">
             <input id="MasterPageForm:userSaveButton" type="submit" name="MasterPageForm:userSaveButton" value="SAVE" class="GekkoCommandButton"/>
             </div>
             </div>
             </td>
             </tr>
             </tbody>
             </table>
             <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id6"/>
             </form>
             </body>
             <script>
            //<![CDATA[
            A4J.AJAX._scriptEvaluated=true;
            //]]>
             </script>
            </html>
            



            OK, now after save it is this (you will notice that we change our input components to straight output after the save is clicked)

            <?xml version="1.0" encoding="UTF-8"?>
            <html xmlns="http://www.w3.org/1999/xhtml">
             <head>
             ...(bunch of js imports and css stuff)
             </head>
            ...(a bunch of boring html and javascript)
             </td>
             <td id="menuTabCell" valign="top" align="left" width="30">
             <input id="MasterPageForm:sideMenuState" type="hidden" name="MasterPageForm:sideMenuState" value="true"/>
             <img id="MasterPageForm:sideMenuTab" src="/gekko-tje/images/menu_tab.jpg" onclick="toggleSideMenuDisplay()" style="cursor:pointer"/>
             </td>
             <td style="margin-left: 3em;" valign="top">
             <div class="FormViewport">
             <dl id="MasterPageForm:j_id49" class="rich-messages errorPanel messageText" style="display: none; null">
             <dt>
             <span class="rich-messages-label">
             </span>
             </dt>
             </dl>
             <dl id="MasterPageForm:j_id52" class="rich-messages infoPanel messageText" style="display: none; null">
             <dt>
             <span class="rich-messages-label">
             </span>
             </dt>
             </dl>
             <dl id="MasterPageForm:j_id54" class="rich-messages warnPanel messageText" style="display: none; null">
             <dt>
             <span class="rich-messages-label">
             </span>
             </dt>
             </dl>
             <h1>
             User Details
             </h1>
             <div id="MasterPageForm:summaryPanel" class="summaryBox">
             <span class="summaryLabel rightAlign">
             User:
             </span>
             <span class="summaryText rightAlign">
             UserMaintenanceTestSurname, UserTestFirstname:2008-09-01 12:42:08.910
             </span>
             <span class="summaryLabel rightAlign">
             Login ID:
             </span>
             <span class="summaryText rightAlign">
             Known User
             </span>
             </div>
             <div class="gekkoTabGroup">
             <input id="MasterPageForm:detailsTab" type="submit" name="MasterPageForm:detailsTab" value="Details"/>
             <input id="MasterPageForm:rolesTab" type="submit" name="MasterPageForm:rolesTab" value="Roles"/>
             <input id="MasterPageForm:workgroupsTab" type="submit" name="MasterPageForm:workgroupsTab" value="Workgroups"/>
             <input id="MasterPageForm:districtsTab" type="submit" name="MasterPageForm:districtsTab" value="Districts"/>
             </div>
             <div id="MasterPageForm:detailsFormPanel" class="panelbox">
             <table id="MasterPageForm:mainGrid" class="formTable" width="100%">
             <tbody>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:locked" class="FormLabel ">
             Account locked:
             </label>
             <input id="MasterPageForm:locked" type="checkbox" name="MasterPageForm:locked" checked="checked" class="checkbox" disabled="disabled" readonly="readonly" value="on"/>
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:login" class="FormLabel ">
             Login ID:
             <span class="required">
             *
             </span>
             </label>
             Known User
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:title" class="FormLabel ">
             Title:
             <span class="required">
             *
             </span>
             </label>
             system
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:lastname" class="FormLabel ">
             Surname:
             <span class="required">
             *
             </span>
             </label>
             UserMaintenanceTestSurname
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:firstname" class="FormLabel ">
             Given name:
             <span class="required">
             *
             </span>
             </label>
             UserTestFirstname:2008-09-01 12:42:08.910
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:district" class="FormLabel ">
             Default District:
             <span class="required">
             *
             </span>
             </label>
             Brisbane Corporate Headquarters
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:location" class="FormLabel ">
             Location:
             <span class="required">
             *
             </span>
             </label>
             Headquarters
             </span>
             </td>
             </tr>
             <tr>
             <td>
             <span class="FormRow">
             <label for="MasterPageForm:position" class="FormLabel ">
             Position:
             </label>
             UserMaintenanceTestPosition
             </span>
             </td>
             </tr>
             </tbody>
             </table>
             </div>
             <div class="mainButtonGroup">
             <input id="MasterPageForm:userEditButton" type="submit" name="MasterPageForm:userEditButton" value="EDIT" class="GekkoCommandButton"/>
             </div>
             </div>
             </td>
             </tr>
             </tbody>
             </table>
             <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id7"/>
             </form>
             </body>
            </html>
            



            So, up till this point everything is fine. Save is doing what it should do. And the page content is what I would expect.

            But now I do the
            templatepage.clickRolesTab();


            And this is the resulting page
            <?xml version="1.0" encoding="ISO-8859-1"?>
            <html>
             <body/>
            </html>
            



            • 3. Re: Beta3 clicking on command Button is broken
              Tim Evers Master

              OK!!!! I have found at least where I can point the finger (I think :P)

              I decided to play around with the other jars that I updated when I went to beta 3 to see if they made any difference.
              Sure enough they do!

              With beta 2 (I guess that'w what it was called :P) I was using htmlunit-2.2-SNAPSHOT (I'll have to figure out what minor version/build or whatever but that's what I was using).
              With this jar and beta 2 everything was working fine. So, when I upgraded to beta 3, I also updated to the official htmlunit-2.2.jar release.

              This is actually what is causing the problem. If I go back to the SNAPSHOT jar while still running beta3 everything is fine.

              So, I really don't know where to look in htmlunit but.... that's where the bug lies I would think.
              If you need any more info from me to help with this issue please let me know. I still think we should be able to run the official release of htmlunit so it would be nice if this bug could be fixed.

              So, Stan, seeings as you have a much better understanding of how htmlunit integrates with jsfunit would you be able to raise the bug with them or point me to where I should look to find the bug so I can report it?

              Thanks,
              Tim

              • 4. Re: Beta3 clicking on command Button is broken
                Stan Silvert Master

                Hi Tim,

                I'll try to take a look as soon as I can. Today is a holiday in the US and then I have to get ready for JSFOne. But hopefully I'll get to it.

                Since you've narrowed it down to an HtmlUnit problem, you might want to try building HtmlUnit from their SVN. I know that they have fixed at least one JSFUnit-related bug since releasing 2.2.

                Stan

                • 5. Re: Beta3 clicking on command Button is broken
                  Tim Evers Master

                  I can't build from their SVN. All I get is corrupt jar files and all sorts of errors.

                  • 6. Re: Beta3 clicking on command Button is broken
                    Stan Silvert Master

                    Hmm. I couldn't build it either. I wonder what's going on.

                    Stan