1 Reply Latest reply on Feb 25, 2008 9:53 AM by Stan Silvert

    Disable/Enable of buttons

    steve alex Newbie

      Hi

      how to test the disable and enable of buttons. using jsfunit


      Thanks

        • 1. Re: Disable/Enable of buttons
          Stan Silvert Master

          You have several ways to test this. Assume you have a command button defined like this:

          <h:commandButton value="Hello" action="/index.jsp" id="submit_button" disabled="#{mybean.enabled}"/>


          You can test this from the server side using the JSFServerSession like this:
          JSFServerSession server = new JSFServerSession(client);
          HtmlCommandButton submitButton = (HtmlCommandButton)server.findComponent("submit_button");
          assertTrue(submitButton.isDisabled());


          From the client side you have several ways to find the component but the simplest in this case is to use the HttpUnit API:
          WebResponse response = client.getWebResponse();
          String clientID = client.getClientIDs().findClientID("submit_button");
          Button submitButton = (Button)response.getElementWithID(clientID);
          assertTrue(submitButton.isDisabled());


          I prefer testing this sort of thing from the server side, which is a bit more powerful.

          Stan