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.jameleon.plugin.jiffie.util.IEUtility;
24
25 /***
26 * Sends the provided keys to the screen.
27 *
28 * Please see
29 * <a target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/4b032417-ebda-4d30-88a4-2b56c24affdd.asp">IE SendKeys method docs</a>
30 * for specs on how to represent keys.
31 * NOTE: the <b>windowTitle</b> is the text that appears on the top left of the actual window. For example,
32 * the Calculator application has a title of "Calculator".
33 * @jameleon.function name="ie-send-keys" type="action"
34 * @jameleon.step Find the window with the provided title
35 * @jameleon.step Send the provided keys to that window
36 */
37 public class IESendKeysTag extends IEFunctionTag {
38
39 /***
40 * The title of the window to send keys to.
41 * @jameleon.attribute required="true" contextName="ieSendKeysWindowTitle"
42 */
43 protected String windowTitle;
44 /***
45 * The keys to send to the screen
46 * @jameleon.attribute required="true" contextName="ieSendKeysKeys"
47 */
48 protected String keys;
49 /***
50 * The maximum number of seconds to wait before failing.
51 * @jameleon.attribute required="true" contextName="ieSendKeysMaxWaitTime" default="30"
52 */
53 protected int maxWaitTime;
54 /***
55 * The maximum number of seconds to wait before failing.
56 * @jameleon.attribute contextName="ieSendKeysFailOnWindowNoFound" default="true"
57 */
58 protected boolean failOnWindowNotFound;
59
60 public void testBlock() {
61 boolean windowFound = IEUtility.sendKeys(windowTitle, keys, maxWaitTime*10);
62 if (failOnWindowNotFound) {
63 assertTrue("A window with the title '"+windowTitle+"' was not found", windowFound);
64 }
65 }
66 }