You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sven Schliesing <sc...@subshell.com> on 2008/02/28 16:51:12 UTC

Testing (Ajax)TabbedPanel

Hey,

I've written a test for a page which contains an "AjaxTabbedPanel". 
Right now I'm testing the click on the second tab like this:

AjaxTabbedPanel tabbedPanel = (AjaxTabbedPanel)
   tester.getComponentFromLastRenderedPage("panel:tabPanel");
WebMarkupContainer tabs = (WebMarkupContainer)
   tabbedPanel.get("tabs-container:tabs");

WebMarkupContainer siteTab = (WebMarkupContainer) tabs.get("1");
AjaxFallbackLink sitesTabLink = (AjaxFallbackLink) siteTab.get("link");
		
tester.clickLink(sitesTabLink.getPageRelativePath(), true);


This works quite good. But I'm having problems with using too much 
"internal knowledge" (e.g. the tabs-container id) of the AjaxTabbedPanel.

Sure, this is more an academically problem. But I'd like to know if 
there's a better approach.


Thanks in advance!


Sven

-- 
subshell GmbH
Sven Schliesing
Margaretenstraße 43a                t +49.40.431 362-23
20357 Hamburg                       f +49.40.431 362-29
http://www.subshell.com             schliesing@subshell.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Testing (Ajax)TabbedPanel

Posted by Kent Tong <ke...@cpttm.org.mo>.

Sven Schliesing wrote:
> 
> This works quite good. But I'm having problems with using too much 
> "internal knowledge" (e.g. the tabs-container id) of the AjaxTabbedPanel.
> 

You can always create your own TabPanelTester that may have a getTab(id) 
method. This class will encapsulate the internal knowledge.


-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
-- 
View this message in context: http://www.nabble.com/Testing-%28Ajax%29TabbedPanel-tp15739429p15772312.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Testing (Ajax)TabbedPanel

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Thu, 28 Feb 2008, Sven Schliesing wrote:
> This works quite good. But I'm having problems with using too much 
> "internal knowledge" (e.g. the tabs-container id) of the AjaxTabbedPanel.
> 
> Sure, this is more an academically problem. But I'd like to know if 

It's not plain academic, because this issue makes your tests
more fragile. From early 1.3 through the beta versions and
now to 1.3.1, our tests have been breaking up sometimes, for
example for issues like that. It can also happen with your
own code when its component hierarchy changes.

> there's a better approach.

Yes, you can use Component.visitChildren(Class, IVisitor) to
operate on the wanted component on the hierarchy. 

jdave-wicket has this built-in
(ComponentSpecification.selectFirst() and .selectAll()) and
even the cool feature of being able to find the component
with a Hamcrest matcher matching on its model object.

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org