View Javadoc

1   /*
2       Jiffie Plugin for Jameleon - An Internet Explorer plug-in for Jameleon
3       Copyright (C) 2004-2006 Christian W. Hargraves (engrean@hotmail.com) and
4                          Matthias Marschall (matthias@marschalls.de)
5   
6       This program is free software; you can redistribute it and/or modify
7       it under the terms of the GNU General Public License as published by
8       the Free Software Foundation; either version 2 of the License, or
9       (at your option) any later version.
10  
11      This program is distributed in the hope that it will be useful,
12      but WITHOUT ANY WARRANTY; without even the implied warranty of
13      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14      GNU General Public License for more details.
15  
16      You should have received a copy of the GNU General Public License
17      along with this program; if not, write to the Free Software
18      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20  package net.sf.jameleon.plugin.jiffie.tags;
21  
22  import net.sf.jameleon.plugin.jiffie.IEFunctionTag;
23  
24  /***
25   * Validates text or a regular expression can be found in the current HTML document.
26   * 
27   * Some examples might be:
28   * 
29   * Verify the page has the text 'some text on the page' is on the current page
30   * <pre><source>
31   *  &lt;ie-validate-text functionId="Verify that 'some text on the page' exists on the current page."
32   *       text="some text on the page" /&gt;
33   * </source></pre>
34   * Verify the page has text that looks like a date '12/21/2006' on the current page, but we don't care about the exact value.
35   * <pre><source>
36   *  &lt;ie-validate-text functionId="Verify the page has text that looks like a date '12/21/2006' on the current page"
37   *       text="[//d]{2}/[//d]{2}/[//d]{4}"
38   *       regex="true" /&gt;
39   * </source></pre>
40   * @jameleon.function name="ie-validate-text" type="validation"
41   * @jameleon.step Assert that given text or regular expression is present in current document.
42   */
43  public class IEValidateTextTag extends IEFunctionTag {
44  
45      /***
46       * The text to validate the existence of.
47       * @jameleon.attribute required="true" contextName="ieValidateTextText"
48       */
49      protected String text;
50  
51      /***
52       * Specifies whether the text represents a regular expression.
53       *
54       * @jameleon.attribute required="false" contextName="ieValidateTextRegex"
55       */
56      protected boolean regex;
57  
58      public void testBlock() {
59          assertTextPresent(text, regex);
60      }
61  }