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.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   *  &lt;ie-click-html-element functionId="Click an image button with the src ending in jameleon.jpg"
34   *                     htmlElement="input"&gt;
35   *     &lt;ie-attribute&gt;
36   *         &lt;ie-attribute-name&gt;type&lt;/ie-attribute-name&gt;
37   *         &lt;ie-attribute-value&gt;image&lt;/ie-attribute-value&gt;
38   *     &lt;/ie-attribute&gt;
39   *     &lt;ie-attribute&gt;
40   *         &lt;ie-attribute-name&gt;src&lt;/ie-attribute-name&gt;
41   *         &lt;ie-attribute-value&gt;jameleon.jpg&lt;/ie-attribute-value&gt;
42   *     &lt;/ie-attribute&gt;
43   * &lt;/ie-click-html-element&gt;
44   * </source></pre>
45   * Clicking on &lt;input type="image" src="jameleon.jpg" alt="jameleon image" &gt; based on the alt text alone
46   * <pre><source>
47   *  &lt;ie-click-html-element functionId="Click an image button with the alt text"
48   *                     htmlElement="input"&gt;
49   *     &lt;ie-attribute&gt;
50   *         &lt;ie-attribute-name&gt;type&lt;/ie-attribute-name&gt;
51   *         &lt;ie-attribute-value&gt;image&lt;/ie-attribute-value&gt;
52   *     &lt;/ie-attribute&gt;
53   *     &lt;ie-attribute&gt;
54   *         &lt;ie-attribute-name&gt;alt&lt;/ie-attribute-name&gt;
55   *         &lt;ie-attribute-value&gt;jamaleon image&lt;/ie-attribute-value&gt;
56   *     &lt;/ie-attribute&gt;
57   * &lt;/ie-click-html-element&gt;
58   * </source></pre>
59   * Clicking on &lt;input type="image" src="jameleon.jpg" alt="jameleon image" &gt; with both alt text and image src
60   * <pre><source>
61   *  &lt;ie-click-html-element functionId="Click an image button with the alt text"
62   *                     htmlElement="input"&gt;
63   *     &lt;ie-attribute&gt;
64   *         &lt;ie-attribute-name&gt;type&lt;/ie-attribute-name&gt;
65   *         &lt;ie-attribute-value&gt;image&lt;/ie-attribute-value&gt;
66   *     &lt;/ie-attribute&gt;
67   *     &lt;ie-attribute&gt;
68   *         &lt;ie-attribute-name&gt;alt&lt;/ie-attribute-name&gt;
69   *         &lt;ie-attribute-value&gt;jamaleon image&lt;/ie-attribute-value&gt;
70   *     &lt;/ie-attribute&gt;
71   *     &lt;ie-attribute&gt;
72   *         &lt;ie-attribute-name&gt;src&lt;/ie-attribute-name&gt;
73   *         &lt;ie-attribute-value&gt;jameleon.jpg&lt;/ie-attribute-value&gt;
74   *     &lt;/ie-attribute&gt;
75   *  &lt;/ie-click-html-element&gt;
76   * </source></pre>
77   * Clicking on &lt;a href="http://sf.net" id="sf link" &gt;
78   * <pre><source>
79   *  &lt;ie-click-html-element functionId="Click an anchor tag"
80   *                     htmlElement="a"&gt;
81   *     &lt;ie-attribute&gt;
82   *         &lt;ie-attribute-name&gt;id&lt;/ie-attribute-name&gt;
83   *         &lt;ie-attribute-value&gt;sf link&lt;/ie-attribute-value&gt;
84   *     &lt;/ie-attribute&gt;
85   *  &lt;/ie-click-html-element&gt;
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 }