How to type into input field with WicketTester?
Asked Answered
E

1

6

I'm writing a unit test for a Wicket WebPage. I want to fire up a page, type into a field, click a link, and then make some assertions.

Looking at the API of WicketTester and BaseWicketTester, I couldn't find any method that takes a path (like "form:input") to locate an input field and lets you enter text in it.

// set up WicketTester; create page
tester.startPage(page);
tester. // Type into input field - how to do this?
tester.clickLink("form:continueButton");
// assert something

Did I miss something? This seems like a pretty basic use case. Are you not supposed to use WicketTester like this? (That would be surprising given the presence of methods like clickLink().)

Evelinevelina answered 26/10, 2010 at 8:32 Comment(0)
A
9

Use FormTester:

FormTester formTester = tester.newFormTester("form");
formTester.setValue("myformfield", "Hello Sailor");

Reference:

Almena answered 26/10, 2010 at 8:49 Comment(1)
Ah, so that's how you're supposed to do it. Thanks!Evelinevelina

© 2022 - 2024 — McMap. All rights reserved.