You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jan Eriksson <jn...@gmail.com> on 2010/03/04 17:41:18 UTC
Can't get FormTester.submitLink to work (required testfield always
missing)
I'm stuck on something that seems like a very trivial problem.. I have
a form with a RequiredTextField that i want to run some tests on using
FormTester. The form is submitted using a SubmitLink located outside
of the <form> tags. My problem is that even when i set a value on the
RequiredTextField the form submission is failing - because of that the
required field is missing.
test-code:
tester.startPage(HomePage.class);
tester.assertRenderedPage(HomePage.class);
FormTester formTester = tester.newFormTester("testForm", false);
formTester.setValue("name", "a name");
formTester.submitLink("mySubmitLink", true);
tester.assertNoErrorMessage();
java-code:
public class HomePage extends WebPage {
private static final long serialVersionUID = 1L;
private final ValueMap properties = new ValueMap();
public HomePage(final PageParameters parameters) {
Form<Object> f = new Form<Object>("testForm", new
CompoundPropertyModel<Object>(properties));
add(f);
f.add(new RequiredTextField<String>("name"));
add(new SubmitLink("mySubmitLink", f));
}
}
markup:
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"
>
<body>
<form wicket:id="testForm">
<input wicket:id="name"></input>
</form>
<a href="#" wicket:id="mySubmitLink">submit</a>
</body>
</html>
stacktrace:
junit.framework.AssertionFailedError: expect no error message, but contains
Field 'name' is required.
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.assertTrue(Assert.java:20)
at org.apache.wicket.util.tester.WicketTester.assertNoErrorMessage(WicketTester.java:501)
at com.metria.test.atest.TestHomePage.testRenderMyPage(TestHomePage.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Any help would be appreciated! Thanks,
jan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can't get FormTester.submitLink to work (required testfield
always missing)
Posted by Kent Tong <ke...@cpttm.org.mo>.
jn73 wrote:
>
> My problem is that even when i set a value on the
> RequiredTextField the form submission is failing - because of that the
> required field is missing.
>
Please try http://wicketpagetest.sourceforge.net. It should work.
-----
--
Kent Tong
Better way to unit test Wicket pages (http://wicketpagetest.sourceforge.net)
Books on CXF, Axis2, Wicket, JSF (http://agileskills2.org)
--
View this message in context: http://old.nabble.com/Can%27t-get-FormTester.submitLink-to-work-%28required-testfield-always--missing%29-tp27783318p27788850.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can't get FormTester.submitLink to work (required testfield
always missing)
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
Create a quickstart (Wicket 1.5+)
On Mon, Mar 19, 2012 at 7:54 PM, Fabio Sakiyama <fa...@gmail.com> wrote:
> Hi Martin,
>
> Thx for answering,
>
> Hmm, i dont know the jira's conxtext on wicket, but where i use it, i create
> a jira when there's actually a problem.
> I don't think it is a wicket problem (idk, just guessing), probably it's
> just me not using it correctly.
>
> I didn't create a new post cause this post reflects my problem.
>
> My problem:
>
> I made a wicketTester for a page, worked perfectly.
> I'm doing the same to other page, but i dont know if its because of the
> submitLink or anything else, its not working.
> My formTester is setting values , but when i do a submitLink and
> assertNoErrorMessage, it fails.
>
> My test is doing this:
>
> this.tester.startPage(CadastroPerfilPropagacao.class);
> this.tester.assertRenderedPage(CadastroPerfilPropagacao.class);
> FormTester formtester = this.tester.newFormTester("mainForm");
> ...
> formtester.setValue("pathFromForm", "VALUE TEST");
> formtester.setValue("pathFromForm", "DESCRIPTION TEST");
> this.tester.executeAjaxEvent("pathFromForm", "onchange");
> formtester.setValue("pathFromFormAfterAjaxEvent", "VALUE");
> ...
> formtester.submitLink("btnAdd", false); <-- This button adds an object
> inside a list
> formtester.submitLink("btnSave", false); <-- This one submits
> this.tester.assertNoErrorMessage();
>
> And then i get the assertionFailed error, it says the fields are required.
>
> I don't know if this helps, if you think the quickstar is still needed,
> please tell me.
>
> Thx
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Can-t-get-FormTester-submitLink-to-work-required-testfield-always-missing-tp1888944p4485748.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can't get FormTester.submitLink to work (required testfield
always missing)
Posted by Fabio Sakiyama <fa...@gmail.com>.
Hi Martin,
Thx for answering,
Hmm, i dont know the jira's conxtext on wicket, but where i use it, i create
a jira when there's actually a problem.
I don't think it is a wicket problem (idk, just guessing), probably it's
just me not using it correctly.
I didn't create a new post cause this post reflects my problem.
My problem:
I made a wicketTester for a page, worked perfectly.
I'm doing the same to other page, but i dont know if its because of the
submitLink or anything else, its not working.
My formTester is setting values , but when i do a submitLink and
assertNoErrorMessage, it fails.
My test is doing this:
this.tester.startPage(CadastroPerfilPropagacao.class);
this.tester.assertRenderedPage(CadastroPerfilPropagacao.class);
FormTester formtester = this.tester.newFormTester("mainForm");
...
formtester.setValue("pathFromForm", "VALUE TEST");
formtester.setValue("pathFromForm", "DESCRIPTION TEST");
this.tester.executeAjaxEvent("pathFromForm", "onchange");
formtester.setValue("pathFromFormAfterAjaxEvent", "VALUE");
...
formtester.submitLink("btnAdd", false); <-- This button adds an object
inside a list
formtester.submitLink("btnSave", false); <-- This one submits
this.tester.assertNoErrorMessage();
And then i get the assertionFailed error, it says the fields are required.
I don't know if this helps, if you think the quickstar is still needed,
please tell me.
Thx
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Can-t-get-FormTester-submitLink-to-work-required-testfield-always-missing-tp1888944p4485748.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can't get FormTester.submitLink to work (required testfield
always missing)
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
Create a quickstart app with Wicket 1.5 and attach it to Jira.
On Mon, Mar 19, 2012 at 6:06 PM, Fabiosakiyam <fa...@gmail.com> wrote:
> Hi,
>
> Old post but, any solutions for this, using wicket tester?
>
> Thx
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Can-t-get-FormTester-submitLink-to-work-required-testfield-always-missing-tp1888944p4485338.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Can't get FormTester.submitLink to work (required testfield
always missing)
Posted by Fabiosakiyam <fa...@gmail.com>.
Hi,
Old post but, any solutions for this, using wicket tester?
Thx
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Can-t-get-FormTester-submitLink-to-work-required-testfield-always-missing-tp1888944p4485338.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org