1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.jameleon.plugin.selenium.tags;
20
21 /***
22 * Validates text on the current page.
23 *
24 * To validate text in a page using regular expressions:
25 * <pre><source>
26 * <selenium-assert-text-present
27 * functionId="Check for text using a regular expression"
28 * pattern="regexp:[Yo]+ W[a-z]{3}" />
29 * </source></pre>
30 * To validate text in a page using the default glob style:
31 * <pre><source>
32 * <selenium-assert-text-present
33 * functionId="Check for text using a glob pattern"
34 * pattern="Y* Wor?d" />
35 * </source></pre>
36 * To validate exact text in a page:
37 * <pre><source>
38 * <selenium-assert-text-present
39 * functionId="Check that the entire reponse only contains 'Yo World'"
40 * pattern="exact:Yo World" />
41 * </source></pre>
42 * NOTE: To do a "glob" search, make sure to not define the prefix.
43 * @jameleon.function name="selenium-assert-text-present" type="validation"
44 */
45 public class SeleniumAssertTextPresentTag extends AbstractSeleniumPatternTag{
46
47 /***
48 * The error message to output if the validation fails.
49 * @jameleon.attribute
50 */
51 protected String msg;
52
53 public void testBlock(){
54 assertTrue(getStringOrDefault(msg, pattern + " was not found!"), session.isTextPresent(pattern));
55 }
56
57 }