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 watij.elements.HtmlElement;
23  import watij.finders.Symbol;
24  
25  /***
26   * Gets a radio button on the page and stores in the context.
27   * 
28   * An example might be to get a radio button via its name:
29   * 
30   * <pre><source>
31   * &lt;testcase xmlns="jelly:jameleon" xmlns:j="jelly:core"&gt;
32   *     &lt;watij-session baseUrl="http://some.url/some/path" beginSession="true"&gt;
33   *         &lt;watij-radio
34   *             functionId="Gets a radio button vi its name"
35   *             how="name"
36   *             what="radioName"
37   *             contextVar="watijRadio"/>
38   *     &lt;/watij-session&gt;
39   * &lt;/testcase&gt;
40   * </source></pre>
41   * 
42   * Maybe there are several radio buttons with the same name:
43   * 
44   * <pre><source>
45   * &lt;testcase xmlns="jelly:jameleon" xmlns:j="jelly:core"&gt;
46   *     &lt;watij-session baseUrl="http://some.url/some/path" beginSession="true"&gt;
47   *         &lt;watij-radio
48   *             functionId="Gets a radio button via its name and value"
49   *             how="name"
50   *             what="radioName"
51   *             value="val2"
52   *             contextVar="watijRadio"/>
53   *     &lt;/watij-session&gt;
54   * &lt;/testcase&gt;
55   * </source></pre>
56   * 
57   * 
58   * See the javadocs on watij's {@link  watij.finders.SymbolFactory SymbolFactory} for a complete list of supported symbols.
59   * @jameleon.function name="watij-radio" type="action"
60   */
61  public class WatijRadioTag extends AbstractWatijGetTag {
62  
63      /***
64       * The value of the form field. 
65       * This is for form fields that all have the same name,
66       * but different values.
67       * @jameleon.attribute
68       */
69      protected String value;
70  
71      public HtmlElement getHtmlElement(Symbol how, String what) throws Exception{
72          HtmlElement radio = null;
73          if (value != null) {
74              radio = ie().radio(how, what, value);
75          }else{
76              radio = ie().radio(how, what);
77          }
78          return radio;
79      }
80  
81      public String getTagName(){
82          return "Radio";
83      }
84  
85  }