View Javadoc

1   /*
2       Jameleon Watij plug-in - A plug-in that uses Watij (http://www.watij.com/) to drive web sites
3       Copyright (C) 2008 Christian W. Hargraves (engrean@hotmail.com)
4   
5       This program is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published by
7       the Free Software Foundation; either version 2 of the License, or
8       (at your option) any later version.
9   
10      This program is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13      GNU General Public License for more details.
14  
15      You should have received a copy of the GNU General Public License
16      along with this program; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  
19  */
20  package net.sf.jameleon.plugin.watij.tags;
21  
22  import watij.elements.HtmlElement;
23  import watij.finders.Symbol;
24  
25  /***
26   * Gets a link on the page and stores in the context.
27   * 
28   * An example of its use might be to click on a link via its underlined text:
29   * 
30   * <pre><source>
31   * &lt;testcase xmlns="jelly:jameleon" xmlns:j="jelly:core"&gt;
32   *     &lt;watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true"&gt;
33   *         &lt;watij-link
34   *             functionId="Get the 'some link' link"
35   *             how="text"
36   *             what="some link"
37   *             contextVar="watijLink"/>
38   *         &lt;watij-click
39   *             functionId="Click on the 'some link' link"
40   *             element="${watijLink}"/>
41   *     &lt;/watij-session&gt;
42   * &lt;/testcase&gt;
43   * </source></pre>
44   * 
45   * Maybe there are several links with the same text and the one of interest has a and id attribute of '42'
46   * and you want to use a more specific context variable name like 'link42':
47   * 
48   * <pre><source>
49   * &lt;testcase xmlns="jelly:jameleon" xmlns:j="jelly:core"&gt;
50   *     &lt;watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true"&gt;
51   *         &lt;watij-link
52   *             functionId="Get the link with the id of '42'"
53   *             how="id"
54   *             what="42"
55   *             contextVar="link42"/>
56   *         &lt;watij-click
57   *             functionId="Click on the link"
58   *             element="${link42}"/>
59   *     &lt;/watij-session&gt;
60   * &lt;/testcase&gt;
61   * </source></pre>
62   * 
63   * See the javadocs on watij's {@link  watij.finders.SymbolFactory SymbolFactory} for a complete list of supported symbols.
64   * @jameleon.function name="watij-link" type="action"
65   */
66  public class WatijLinkTag extends AbstractWatijGetTag{
67  
68      public HtmlElement getHtmlElement(Symbol how, String what) throws Exception{
69          return ie().link(how, what);
70      }
71  
72      public String getTagName(){
73          return "Link";
74      }
75  }