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.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  }