Hi there,
I'm using Wicket 6.4 and try to test a super simple form:
public final class MyForm extends WebPage {
public MyForm() {
super();
Form form = new Form("form");
TextField textField = new TextField("textfield");
textField.setRequired(true);
form.add(textField);
DropDownChoice dropDownChoice = new DropDownChoice("dropdown", new
Model(), new ArrayList(Arrays.asList("a", "b", "c"))){
@Override
protected boolean wantOnSelectionChangedNotifications() {
return true;
}
@Override
protected void onSelectionChanged(Object newSelection) {
System.out.println("change");
}
};
dropDownChoice.setRequired(true);
form.add(dropDownChoice);
form.add(new SubmitLink("submitLink") {
@Override
public void onSubmit() {
// return back to the home page
setResponsePage(HomePage.class);
}
});
add(form);
}
}
My test looks like this:
public class TestMyForm {
private WicketTester tester;
@Before
public void setUp() {
tester = new WicketTester(new WicketApplication());
}
@Test
public void homepageRendersSuccessfully() {
//start and render the test page
tester.startPage(MyForm.class);
//assert rendered page class
tester.assertRenderedPage(MyForm.class);
}
@Test
public void enterData(){
tester.startPage(MyForm.class);
FormTester formTester = tester.newFormTester("form");
formTester.setValue("textfield", "Hello World");
formTester.select("dropdown", 1);
tester.executeAjaxEvent("form:dropdown", "onchange");
formTester.submit();
tester.assertNoErrorMessage();
tester.assertRenderedPage(HomePage.class);
}
}
The result is:
Testcase: enterData(eu.sudus.TestMyForm): FAILED
expect no error message, but contains
'textfield' is required.
'dropdown' is required.
I understand the textfield is less the problem, but the submitting the
dropdownchoice value.
Can someone help me out?
Thanks,
Ralf
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Testing-DropDownChoice-with-Ajax-tp4655418.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]