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 net.sf.jameleon.plugin.watij.WatijFunctionTag;
23  /***
24   * Gets the title of the page and stores it in the context.
25   * 
26   * An example of its use might be to get the title and do logic on it:
27   * 
28   * <pre><source>
29   * &lt;testcase xmlns="jelly:jameleon" xmlns:j="jelly:core"&gt;
30   *     &lt;watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true"&gt;
31   *       &lt;watij-title
32   *           functionId="Check that the title is 'testing'."/&gt;
33   *       &lt;j:if test="${watijTitle eq 'some title'"&gt;
34   *           &lt;watij-click-link
35   *               functionId="Click on the 'some link' link"
36   *               link="some link"/>
37   *       &lt;/j:if&gt;
38   *       &lt;j:if test="${watijTitle eq 'some other title'"&gt;
39   *           &lt;watij-click-link
40   *               functionId="Click on the 'some other link' link"
41   *               link="some other link"/>
42   *       &lt;/j:if&gt;
43   *     &lt;/watij-session&gt;
44   * &lt;/testcase&gt;
45   * </source></pre>
46   * 
47   * To store the title in a context variable other than the default:
48   * 
49   * <pre><source>
50   * &lt;testcase xmlns="jelly:jameleon" xmlns:j="jelly:core"&gt;
51   *     &lt;watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true"&gt;
52   *       &lt;watij-title
53   *           functionId="Check that the title is 'testing'."
54   *           contextVar="testingLink"/&gt;
55   *       &lt;some-tag functionId="use the ${testingLink} title variable"/&gt;
56   *     &lt;/watij-session&gt;
57   * &lt;/testcase&gt;
58   * </source></pre>
59   * 
60   * @jameleon.function name="watij-title" type="action"
61   */
62  public class WatijTitleTag extends WatijFunctionTag{
63  
64      /***
65       * The context variable to store the title in
66       * @jameleon.attribute default="watijTitle" required="true"
67       */
68      protected String contextVar;
69  
70      public void testBlock() throws Exception{
71          setVariable(contextVar, ie().title());
72      }
73  
74  
75  }