I haven't tried it, but the following should work:
FormTester formTester = this.tester.newFormTester("form");
formTester.select("dropDownChoice", 0);
formTester.select("dropDownChoice2", 0);
// the new form tester will transfer all field values into the request
FormTester formTester2 = this.tester.newFormTester("form");
formTester2.setValue("textField", "FOO");
formTester2.submit();
???
Sven
On 01/06/2014 01:32 PM, Kev wrote:
Actually, we don't need a second formTester, just setting the value after
perform the select with the same formTester is working :
FooPage page = this.tester.startPage(FooPage.class);
FormTester formTester = this.tester.newFormTester("form");
formTester.select("dropDownChoice", 0); // ony add this select;
formTester.setValue("textField", "FOO");
formTester.submit();
But in my app, I have two dropdownchoice in the same form. So I can't test
the form because changing one reset the second. So I can't test the values
of my two dropdown like that:
FooPage page = this.tester.startPage(FooPage.class);
FormTester formTester = this.tester.newFormTester("form");
// formTester.setValue("textField", "FOO");
formTester.select("dropDownChoice", 0);
formTester.select("dropDownChoice2", 0);
formTester.setValue("textField", "FOO");
formTester.submit();
assertEquals("FOO", page.getFormValue()); // works only if the
setValue
// was performed before
the
// select
assertEquals("Foo", page.getSelect2Value()); // null
assertEquals("Foo", page.getSelect1Value()); // null
I added a new quickstart with two dropdownchoices.
testWicket.zip
<http://apache-wicket.1842946.n4.nabble.com/file/n4663493/testWicket.zip>
Sven Meier wrote
Thanks for the quickstart.
Sorry, I was wrong :(.
When you select a dropDownChoice' value via FormTester#select(), this
won't trigger a complete Form submit (as it would in the browser). Only
the dropDownChoice is processed.
The following should work:
FooPage page = this.tester.startPage(FooPage.class);
FormTester formTester = this.tester.newFormTester("form");
formTester.select("dropDownChoice", 0); // ony add this select
FormTester formTester2 = this.tester.newFormTester("form");
formTester2.setValue("textField", "FOO");
formTester2.submit();
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Problem-with-FormTester-and-selection-on-dropDownChoice-tp4663439p4663493.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org