I'm trying to write a test case in which I'm having onChange event for
the drop down. I also have textfield as well.
When I submit the form I don't get the value of the textfield.
But if I comment the onChange event call then I'm able to get the value
of the Text Field.
Any help...
@Test
public void testDummyPage() throws Exception
{
TestPage testPage = new TestPage(id);
wicketTester.startPage(testPage);
// assert rendered field components
wicketTester.assertComponent(form:txtName, TextField.class);
wicketTester.assertComponent(form:department,
DropDownChoice.class);
wicketTester.assertComponent(form:employee,
DropDownChoice.class);
FormTester formTester1 = wicketTester.newFormTester(form);
formTester1.setValue(txtName, test);
formTester1.select(department, 0);
wicketTester.executeAjaxEvent(form:department, onchange);
wicketTester.assertComponentOnAjaxResponse(form:employee);
formTester1.select(employee, 1);
formTester1.submit();
Assert.assertEquals(formTester1.getTextComponentValue(txtName),
test);
DropDownChoice dropDownChoice = (DropDownChoice)
wicketTester.getComponentFromLastRenderedPage(
form:department);
System.out.println( dropDownChoice +
dropDownChoice.getModelObjectAsString());
System.out.println( department +
formTester1.getForm().get(department));
Assert.assertEquals((dropDownChoice.getModelObjectAsString()),
HR);
}