This content has been marked as final.
Show 3 replies
-
1. Re: How to test rich:pickList with jsfunit
bgregory Mar 14, 2009 8:17 AM (in response to jadtn)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 Mar 14, 2009 12:32 PM (in response to jadtn)Thanks !
-
3. Re: How to test rich:pickList with jsfunit
jadtn Mar 15, 2009 4:25 AM (in response to 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); } } }