View Javadoc

1   /*
2       Jameleon Watij plug-in - A plug-in that uses Watij (http://www.watij.com/) to drive web sites
3       Copyright (C) 2008 Christian W. Hargraves (engrean@hotmail.com)
4   
5       This program is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published by
7       the Free Software Foundation; either version 2 of the License, or
8       (at your option) any later version.
9   
10      This program is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13      GNU General Public License for more details.
14  
15      You should have received a copy of the GNU General Public License
16      along with this program; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  
19  */
20  package net.sf.jameleon.plugin.watij.tags;
21  
22  import net.sf.jameleon.plugin.watij.WatijFunctionTag;
23  
24  import watij.runtime.ie.IE;
25  
26  /***
27   * Brings the window defined by childBrowserIndex to the front and makes it active. This tag will
28   * wait up to a minute for the new window to display before failing. 
29   * 
30   * For example, to bring the 2nd window to the front:
31   * 
32   * <pre><source>
33   * &lt;testcase xmlns="jelly:jameleon" xmlns:j="jelly:core"&gt;
34   *     &lt;watij-session baseUrl="http://some.url/some/path" beginSession="true"&gt;
35   *         &lt;watij-bring-to-front
36   *             functionId="Bring 2nd window up to the front"
37   *             childBrowserIndex="1"/>
38   *     &lt;/watij-session&gt;
39   * &lt;/testcase&gt;
40   * </source></pre>
41   * 
42   * @jameleon.function name="watij-bring-to-front" type="action"
43   */
44  public class WatijBringToFrontTag extends WatijFunctionTag{
45  
46      /***
47       * The index number of the child browser to activate where the 1st child is <code>0</code>.
48       * @jameleon.attribute
49       */
50      protected Integer childBrowserIndex;
51      /***
52       * Bring the original browser back into focus.
53       * @jameleon.attribute default="false"
54       */
55      protected boolean parentBrowser;
56  
57      public void testBlock() throws Exception{
58          if (parentBrowser) {
59              setCurrentIE(getParentBrowser());
60          }else if (childBrowserIndex != null){
61              IE childBrowser = ie().childBrowser(childBrowserIndex.intValue());
62              childBrowser.bringToFront();
63              childBrowser.focus();
64              setCurrentIE(childBrowser);
65          }
66      }
67  
68  }