How can I test AutoComplete component with WicketTester

193 Views Asked by At

I'm wondering if anyone of you could know how to test auto-complete textfield using wickettester, I have tried

formTester.setValue("path","");
wicketTester.executeAjaxEvent("path","onchange");

I've tried also:

Component component = wicketTester.getComponentFromLastRenderedPage("path");
component.setDefaultModelObject(ObjectNeeded);

But none of these methods worked for me... Any Help will appreciated! Thanks

1

There are 1 best solutions below

2
Don Roby On BEST ANSWER

I have not tried this with real code, but something resembling this might work:

formTester.setValue("path","");

AbstractAutoCompleteBehavior behavior = (AbstractAutoCompleteBehavior)
WicketTesterHelper.findBehavior(wicketTester.getComponentFromLastRenderedPage("path"),
AbstractAutoCompleteBehavior.class);
wicketTester.executeBehavior(behavior);

The findBehavior call actually likely needs to be a longer path, as it's not done by formTester.