you should really use visitors for this kind of thing...something like
this may work very well for you

TestUtils.attachTestId(Component c, String id) {
  if (application.get().getconfigurationtype()!=production) {
      c.setmatadata(testkey, id);
  }
}

then in your code

Form form=new Form(..);
TestUtils.attachTestId(form, "some_unique_form_id");

then in your tests

Page pageundertest=....
Form form=TestUtils.findComponentByTestId(pageundertest, "some_unique_form_id");

you have a potential problem of having collissions for components that
are inside repeaters, but you can set up test harnesses where you test
them in isolation.

-igor


On Fri, May 8, 2009 at 11:23 AM, Martin Makundi
<martin.maku...@koodaripalvelut.com> wrote:
>> I don't know if this is of any help, but I've written the attached
>> utility class that, given a component, can print its containment
>> structure, along with the eventual component classes and
>> model values (toString-ed).
>
> Well... printDoc and wicket
> getDebugSettings().setOutputComponentPath(true); does pretty much the
> same thing.
>
>> See jdave-wicket for better test support. Slated to come to you in Wicket 1.5
>
> How can this help me? For example the following is HELL with wicket:
>
>      Integer round = 1;
>      String mainFormPath = MarkupUtils.getComponentPath(MainPage.MAIN_TABS,
>          TabbedPanel.TAB_PANEL_ID,
>          AbstractInnerPanel.INNER_TABS,
>          MyWizardPanel.WIZARD_FORM);
>      String rowPath =
> MarkupUtils.getComponentPath(MyWizardPanel.FANCY_PANEL_ID,
>          MyPeriodPanel.HISTORY_CONTAINER,
>          MyPeriodPanel.HISTORY_TABLE,
>          MyPeriodPanel.PERIODS,
>          round.toString());
>
>      // Add row
>      tester.executeAjaxEvent(MarkupUtils.getComponentPath(mainFormPath,
>          MyWizardPanel.FANCY_PANEL_ID,
>          MyPeriodPanel.HISTORY_CONTAINER,
>          MyPeriodPanel.BUTTON_CONTAINER,
>          MyPeriodPanel.NEW_BUTTON), "onclick");
>
>      // Fill entry
>      FormTester formTester =
> tester.newFormTester(MarkupUtils.getComponentPath(mainFormPath));
>      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
>          HistoryEditorTable.START_DATE), "26.1.2008");
>      formTester.setValue(MarkupUtils.getComponentPath(rowPath,
>          HistoryEditorTable.DAYS), "5");
>      formTester.select(MarkupUtils.getComponentPath(rowPath,
>          HistoryEditorTable.SETTING), 1);
>
>
> **
> Martin
>
> ---------------------------------------------------------------------
> 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

Reply via email to