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.jiffie.tags;
21
22 import net.sf.jameleon.bean.MatchingTextHelper;
23 import net.sf.jameleon.util.TextMatcher;
24
25 import net.sf.jameleon.plugin.jiffie.IEFunctionTag;
26
27 /***
28 * Gets the matching text against the currently active IE and sets it in the context.
29 *
30 * @author Pravin Bhujbal
31 * @author Christian Hargraves
32 * @jameleon.function name="ie-get-matching-text" type="action"
33 * @jameleon.step Find the given regular expression in the current document
34 * @jameleon.step Store the matching text in the provided variable name.
35 */
36 public class IEGetMatchingTextTag extends IEFunctionTag implements TextMatcher {
37 /***
38 * The name by which a context variable will be created
39 *
40 * @jameleon.attribute contextName="ieGetMatchinTextVarName"
41 */
42 protected String varName;
43 /***
44 * The pattern which is to be used to extract the data from the repsonse
45 *
46 * @jameleon.attribute contextName="ieGetMatchinTextRegex"
47 */
48 protected String regex;
49 /***
50 * The group number (based on parenthesis) to extract the data from.
51 * For example, the following regex has two different groups:
52 * (Some text ([//d]+))
53 *
54 * The first group would be the entire expression. The second group would be
55 * only the matching numbers.
56 * @jameleon.attribute contextName="ieGetMatchinTextRegexGroup"
57 */
58 protected int regexGroup;
59
60 public void testBlock(){
61 MatchingTextHelper helper = new MatchingTextHelper(this);
62 helper.setMatchingTextInContext(varName, regex, regexGroup);
63 }
64
65 /***
66 * Get the text representing the current screen.
67 *
68 * @return String - the text representing the current screen.
69 */
70 public String getCurrentScreenAsText(){
71 return getHTMLSource();
72 }
73
74
75 }