3 Replies Latest reply on Mar 15, 2009 4:25 AM by jadtn

    How to test rich:pickList with jsfunit

    jadtn

      Hello,
      There is someone who have a sample to select values in a rich:picklist with jsfunit?
      Thanks
      Adrien

        • 1. Re: How to test rich:pickList with jsfunit

          The easiest way is to just force the values into the hidden form field that contains the submitted values. This of course doesn't test the control itself, but it will test the form submission and your backing bean.

          public void setPickList(String controlId, String value[]) {
           String derrivedValue = StringUtils.join(value,',');
           // 1) Find control
           HtmlTable table = (HtmlTable)client.getElement(controlId);
           // 2) Find value keeper (valueKeeper)
           HtmlHiddenInput hid = (HtmlHiddenInput)table.getFirstByXPath("//input[contains(@id,'"+controlId+"valueKeeper')]");
           // 3) Set value(s)
           hid.setValueAttribute(derrivedValue == null ? "" : derrivedValue);
          }
          


          This is one of the things on my place for the RichFaces support that I just haven't got to yet. Sorry.

          • 2. Re: How to test rich:pickList with jsfunit
            jadtn

            Thanks !

            • 3. Re: How to test rich:pickList with jsfunit
              jadtn

              Hello

              Gregory's solution works fine, just before he give her solution i've used this (works too):


              public void selectPickList(String id,String... values){
               //first element in the picklist as id=form1:pickList:source::1
               String elementId=id+":source::";
               HtmlPage htmlPage = (HtmlPage)client.getContentPage();
               for (Stringv : values) {
               ClickableElement itemInPickList = (ClickableElement)htmlPage.getElementById(elementId+v);
               try {
               itemInPickList.dblClick();
               } catch (IOException e) {
               throw new RuntimeException(e);
               }
               }
               }