2

I am writing tests for wicket pages. I have three dropdowns on my page. Depending upon the values selected from the dropdowns the panel gets rendered(the panel contains a data table). How do I change the values of the dropdowns from the wicket test so that I can test the rendered panel for different combination of values selected?

sweetcode
  • 159
  • 1
  • 12

1 Answers1

3
@Test
public void testPanel() {
    WicketTester tester = new WicketTester(new JavaWhatApplication()) ;

    DropDownChoice<Type> typeDropDown = 
(DropDownChoice<Type>)tester.getComponentFromLastRenderedPage("categoryForm:types");
    assertEquals(3, typeDropDown.getChoices().size());

    FormTester formTester = tester.newFormTester("categoryForm",false);
    formTester.select("types", 1);   // 1 is index
    tester.executeAjaxEvent("categoryForm:types", "onchange"); 

}

Wicket Quick Guide - Unit Testing

Rangel Preis
  • 394
  • 1
  • 7