You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by "venkataprasad.n" <ve...@hcl.com> on 2011/09/23 09:53:11 UTC

Testing WebMarkupContainer using WicketTester

HI 

I am writing testcases to my one of the wicket applications. I am using
WicketTester and facing problem in testing WebMarkupContainer. 

*Here is my HTML:<br/><HTML>*  <body>
      <wicket:panel>
             <form wicket:id="form">
                     <input type="text" wicket:id="headingText"/>
                     <div wicket:id="wcm">
                         <input type="text" wicket:id="username"/>
                         <input type="text" wicket:id="password"/>
                     </div>
              </form>
      </wicket:panel>
  </body>
</HTML>            

*Java Class:*
public class MyClass extends Panel { 

    MyClass(String id){ 

       super(id); 
       Form form = new Form("form"); 
       TextField text123 = new TextField("headingText"); 
       WebMarkupContainer wcontainer = new WebMarkupContainer("wcm"); 
           wcontainer.add(new TextField("username")); 
           wcontainer.add(new TextField("password")); 

      form.add(text123); 
      form.add(wcontainer); 
     add(form);   

} 
}
*
Now the problem is:*
   WicketTester tester = new WicketTester(.......); 
   tester.startPanel( new TestPanelSource(){ 
      public Panel getTestPanel(String panelId){ 
          return new MyClass("panel"); 
       } 


} 

   tester.assertRenderedPage(MyClass.class)   ---- Working fine 

   // Now I am trying to assert the components in the page 
    tester.assertComponent("panel:form:headingText", TextField.class); --
working fine 
    tester.assertComponent("panel:form:wcm", WebMarkupContainer.class) 
---GIVING PROBLEM. It says that panel:form:wcm is null

   // Alternately I have tried to get the component 
      tester.getComponentFromLastRenderedPage("panel:form:wcm")  -- This is
returning NULL


Could you please tell what might be the problem. It is working fine for
"panel:form:headingText", but not for "panel:form:wcm". 

thanks 
Prasad 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Testing-WebMarkupContainer-using-WicketTester-tp3836082p3836082.html
Sent from the Forum for Wicket Core developers mailing list archive at Nabble.com.

Re: Testing WebMarkupContainer using WicketTester

Posted by Martin Grigorov <mg...@apache.org>.
it looks correct and should work
use the debugger to see why it fails. look for 'children' member of
the form component

On Fri, Sep 23, 2011 at 10:53 AM, venkataprasad.n
<ve...@hcl.com> wrote:
> HI
>
> I am writing testcases to my one of the wicket applications. I am using
> WicketTester and facing problem in testing WebMarkupContainer.
>
> *Here is my HTML:<br/><HTML>*  <body>
>      <wicket:panel>
>             <form wicket:id="form">
>                     <input type="text" wicket:id="headingText"/>
>                     <div wicket:id="wcm">
>                         <input type="text" wicket:id="username"/>
>                         <input type="text" wicket:id="password"/>
>                     </div>
>              </form>
>      </wicket:panel>
>  </body>
> </HTML>
>
> *Java Class:*
> public class MyClass extends Panel {
>
>    MyClass(String id){
>
>       super(id);
>       Form form = new Form("form");
>       TextField text123 = new TextField("headingText");
>       WebMarkupContainer wcontainer = new WebMarkupContainer("wcm");
>           wcontainer.add(new TextField("username"));
>           wcontainer.add(new TextField("password"));
>
>      form.add(text123);
>      form.add(wcontainer);
>     add(form);
>
> }
> }
> *
> Now the problem is:*
>   WicketTester tester = new WicketTester(.......);
>   tester.startPanel( new TestPanelSource(){
>      public Panel getTestPanel(String panelId){
>          return new MyClass("panel");
>       }
>
>
> }
>
>   tester.assertRenderedPage(MyClass.class)   ---- Working fine
>
>   // Now I am trying to assert the components in the page
>    tester.assertComponent("panel:form:headingText", TextField.class); --
> working fine
>    tester.assertComponent("panel:form:wcm", WebMarkupContainer.class)
> ---GIVING PROBLEM. It says that panel:form:wcm is null
>
>   // Alternately I have tried to get the component
>      tester.getComponentFromLastRenderedPage("panel:form:wcm")  -- This is
> returning NULL
>
>
> Could you please tell what might be the problem. It is working fine for
> "panel:form:headingText", but not for "panel:form:wcm".
>
> thanks
> Prasad
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Testing-WebMarkupContainer-using-WicketTester-tp3836082p3836082.html
> Sent from the Forum for Wicket Core developers mailing list archive at Nabble.com.
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com