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 * Looks for the given text on the page.
25 * It then stores whether it was found or not under the provided context
26 * variable name.
27 *
28 * An example of its use might be:
29 *
30 * <pre><source>
31 * <testcase xmlns="jelly:jameleon">
32 * <watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true">
33 * <watij-contains-text
34 * functionId="Check that the word 'Testing' exists on the page."
35 * text="Testing"/>
36 * <ju-assert-true
37 * functionId="Validate that the text was found"
38 * test="${watijTextPresent}"/>
39 * </watij-session>
40 * </testcase>
41 * </source></pre>
42 *
43 * To change the context variable name:
44 *
45 * <pre><source>
46 * <testcase xmlns="jelly:jameleon">
47 * <watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true">
48 * <watij-contains-text
49 * functionId="Check that the word 'Testing' exists on the page."
50 * text="Testing"
51 * contextVar="testingExists"/>
52 * <ju-assert-true
53 * functionId="Validate that the text was found"
54 * test="${testingExists}"/>
55 * </watij-session>
56 * </testcase>
57 * </source></pre>
58 *
59 * @jameleon.function name="watij-contains-text" type="action"
60 */
61 public class WatijContainsTextTag extends WatijFunctionTag{
62
63 /***
64 * The text to check for against the currently active IE.
65 * @jameleon.attribute
66 */
67 protected String text;
68 /***
69 * The context variable to store the title in
70 * @jameleon.attribute default="watijTextPresent" required="true"
71 */
72 protected String contextVar;
73
74 public void testBlock() throws Exception{
75 if (text != null) {
76 setVariable(contextVar, new Boolean(ie().containsText(text)));
77 }
78 }
79
80
81 }