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.plugin.jiffie.IEFunctionTag;
23 import net.sf.jiffie.IHTMLAnchorElement;
24
25 /***
26 * Clicks on a given link.
27 *
28 * Some example uses might be:
29 *
30 * Clicking on <a href="http://sf.net">link text</a>
31 * <pre><source>
32 * <ie-click-link functionId="Click an link with the text underlined"
33 * link="link text"/>
34 * </source></pre>
35 * Clicking on <a href="http://sf.net" id="link id">link text</a>
36 * <pre><source>
37 * <ie-click-link functionId="Click an link with the id"
38 * link="link id"/>
39 * </source></pre>
40 * Clicking on <a href="http://sf.net" name="link name">link text</a>
41 * <pre><source>
42 * <ie-click-link functionId="Click an link with the name"
43 * link="link name"/>
44 * </source></pre>
45 * Clicking on <a href="http://sf.net"><img src="jameleon.jpg"></a>
46 * <pre><source>
47 * <ie-click-link functionId="Click an link with the img src"
48 * link="jameleon.jpg"/>
49 * </source></pre>
50 * Clicking on <a href="http://sf.net"><img src="jameleon.jpg" alt="img alt"></a>
51 * <pre><source>
52 * <ie-click-link functionId="Click an link with the img alt text"
53 * link="img alt"/>
54 * </source></pre>
55 * @jameleon.function name="ie-click-link" type="navigation"
56 * @jameleon.step Validate that the given link is present on the page.
57 * @jameleon.step Click on the given link.
58 */
59 public class IEClickLinkTag extends IEFunctionTag {
60
61 /***
62 * Link (link text, id, alt, name or img src) in page to be clicked.
63 *
64 * @jameleon.attribute required="false" contextName="ieClickLink"
65 */
66 protected String link;
67 /***
68 * Ignore target
69 * If set to 'true', will not open link in new window (if the link has a target).
70 *
71 * @jameleon.attribute required="false" contextName="ieClickLinkIgnoreTarget" default="false"
72 */
73 protected boolean ignoreTarget;
74 /***
75 * Link (link text, id, alt, name, regex or img src) in the page to be clicked.
76 *
77 * @jameleon.attribute required="false" contextName="ieClickLinkHref"
78 */
79 protected String href;
80
81 public void testBlock() {
82 IHTMLAnchorElement anchor;
83 if (href != null && href.length() > 0) {
84 anchor = assertLinkWithHrefPresent(href, link);
85 } else {
86 assertLinkPresent(link);
87 anchor = getLink(link);
88 }
89 clickLink(anchor, ignoreTarget);
90 }
91 }