sweetcode
sweetcode

Reputation: 159

testing wicket pages

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?

Upvotes: 2

Views: 1561

Answers (1)

Rangel Preis
Rangel Preis

Reputation: 394

@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

Upvotes: 3

Related Questions