1

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

hzitoun
  • 5,492
  • 1
  • 36
  • 43

1 Answers1

1

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.

Don Roby
  • 40,677
  • 6
  • 91
  • 113
  • Hi @don roby, I'm using a very old version of wicket(1.4) and most of the method like findBehavior are not implemented yet with this version. I have looked the source code of this method and I have found that inside they are using other methods that also haven't been implemented yet..., so I don't think i'm going to reimplement all of these methods, also I can't change to a recent version of wickettester because the project was developed with the version 1.4... – hzitoun Jul 09 '14 at 09:33
  • When I was doing 1.4, I think I had to write my own findBehavior to do anything resembling this. So with a bit more work, you might be able to accomplish it even in 1.4. – Don Roby Jul 09 '14 at 11:21