1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 * <testcase xmlns="jelly:jameleon" xmlns:j="jelly:core">
30 * <watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true">
31 * <watij-title
32 * functionId="Check that the title is 'testing'."/>
33 * <j:if test="${watijTitle eq 'some title'">
34 * <watij-click-link
35 * functionId="Click on the 'some link' link"
36 * link="some link"/>
37 * </j:if>
38 * <j:if test="${watijTitle eq 'some other title'">
39 * <watij-click-link
40 * functionId="Click on the 'some other link' link"
41 * link="some other link"/>
42 * </j:if>
43 * </watij-session>
44 * </testcase>
45 * </source></pre>
46 *
47 * To store the title in a context variable other than the default:
48 *
49 * <pre><source>
50 * <testcase xmlns="jelly:jameleon" xmlns:j="jelly:core">
51 * <watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true">
52 * <watij-title
53 * functionId="Check that the title is 'testing'."
54 * contextVar="testingLink"/>
55 * <some-tag functionId="use the ${testingLink} title variable"/>
56 * </watij-session>
57 * </testcase>
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 }