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.jiffie.IHTMLElement;
23
24 /***
25 * Clicks a provided html element.
26 * This element can be anything that can be clicked like a link,
27 * a button, an image, or even just some element like a text field.
28 *
29 * Some example uses might be:
30 *
31 * Clicking on <input type="image" src="jameleon.jpg">
32 * <pre><source>
33 * <ie-click-html-element functionId="Click an image button with the src ending in jameleon.jpg"
34 * htmlElement="input">
35 * <ie-attribute>
36 * <ie-attribute-name>type</ie-attribute-name>
37 * <ie-attribute-value>image</ie-attribute-value>
38 * </ie-attribute>
39 * <ie-attribute>
40 * <ie-attribute-name>src</ie-attribute-name>
41 * <ie-attribute-value>jameleon.jpg</ie-attribute-value>
42 * </ie-attribute>
43 * </ie-click-html-element>
44 * </source></pre>
45 * Clicking on <input type="image" src="jameleon.jpg" alt="jameleon image" > based on the alt text alone
46 * <pre><source>
47 * <ie-click-html-element functionId="Click an image button with the alt text"
48 * htmlElement="input">
49 * <ie-attribute>
50 * <ie-attribute-name>type</ie-attribute-name>
51 * <ie-attribute-value>image</ie-attribute-value>
52 * </ie-attribute>
53 * <ie-attribute>
54 * <ie-attribute-name>alt</ie-attribute-name>
55 * <ie-attribute-value>jamaleon image</ie-attribute-value>
56 * </ie-attribute>
57 * </ie-click-html-element>
58 * </source></pre>
59 * Clicking on <input type="image" src="jameleon.jpg" alt="jameleon image" > with both alt text and image src
60 * <pre><source>
61 * <ie-click-html-element functionId="Click an image button with the alt text"
62 * htmlElement="input">
63 * <ie-attribute>
64 * <ie-attribute-name>type</ie-attribute-name>
65 * <ie-attribute-value>image</ie-attribute-value>
66 * </ie-attribute>
67 * <ie-attribute>
68 * <ie-attribute-name>alt</ie-attribute-name>
69 * <ie-attribute-value>jamaleon image</ie-attribute-value>
70 * </ie-attribute>
71 * <ie-attribute>
72 * <ie-attribute-name>src</ie-attribute-name>
73 * <ie-attribute-value>jameleon.jpg</ie-attribute-value>
74 * </ie-attribute>
75 * </ie-click-html-element>
76 * </source></pre>
77 * Clicking on <a href="http://sf.net" id="sf link" >
78 * <pre><source>
79 * <ie-click-html-element functionId="Click an anchor tag"
80 * htmlElement="a">
81 * <ie-attribute>
82 * <ie-attribute-name>id</ie-attribute-name>
83 * <ie-attribute-value>sf link</ie-attribute-value>
84 * </ie-attribute>
85 * </ie-click-html-element>
86 * </source></pre>
87 * @jameleon.function name="ie-click-html-element" type="action"
88 * @jameleon.step Find an element the the provided attribute names and values.
89 * @jameleon.step Click the element if found.
90 */
91 public class IEClickHtmlElementTag extends IEFireEventTag {
92
93 public void testBlock() {
94 IHTMLElement element = getElementToFireEvent();
95 if (element != null) {
96 fireEvent(element);
97 clickIHTMLElement(element);
98 }else{
99 fail("No matching element was found while trying to click on a '"+htmlElement+"' html element!");
100 }
101 }
102
103 }