KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > test > web > unit > ClickLink


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.test.web.unit;
6
7 import org.exoplatform.test.web.*;
8 import com.meterware.httpunit.*;
9 /**
10  * May 21, 2004
11  * @author: Tuan Nguyen
12  * @email: tuan08@users.sourceforge.net
13  * @version: $Id: ClickLink.java,v 1.1 2004/10/11 23:36:06 tuan08 Exp $
14  **/

15 public class ClickLink extends WebUnit {
16   private String JavaDoc textLink_ ;
17
18   public ClickLink(String JavaDoc name, String JavaDoc description) {
19     super(name, description) ;
20   }
21   
22   public ClickLink setTextLink(String JavaDoc text) {
23     textLink_ = text ;
24     return this ;
25   }
26   
27   public WebResponse execute(WebResponse previousResponse,WebTable block,
28                                ExoWebClient client) throws Exception JavaDoc {
29     WebLink link = Util.findLink(previousResponse, block, textLink_) ;
30     if(link != null) return link.click() ;
31     throw new Exception JavaDoc("Cannot find the link: " + textLink_ + ", Block ID " + getBlockId()) ;
32   }
33   
34   public String JavaDoc getActionDescription() {
35     return "This web unit look for the link with the exact matched text '" + textLink_ + "' and click on it";
36   }
37 }
Popular Tags