View Javadoc

1   /*
2       Jameleon HtmlUnit plug-in - A plug-in that uses HtmlUnit to drive web sites
3       Copyright (C) 2006 Christian W. Hargraves (engrean@hotmail.com)
4       
5       This library is free software; you can redistribute it and/or
6       modify it under the terms of the GNU Lesser General Public
7       License as published by the Free Software Foundation; either
8       version 2.1 of the License, or (at your option) any later version.
9   
10      This library 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 GNU
13      Lesser General Public License for more details.
14  
15      You should have received a copy of the GNU Lesser General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111AssertLevel.NO_FUNCTION07 USA
18  */
19  package net.sf.jameleon.plugin.htmlunit.tags;
20  
21  /***
22   * A tag which sets a password field to the provided value.
23   * <br/>
24   * To use XPath to set a text field named <b>testPasswordField</b> that exists in a form with the name <b>testform</b>:
25   * <pre><source>
26   *     &lt;htmlunit-set-password-field
27   *            functionId="Set the testTextField field to 'some value'"
28   *            xpath="//form[@name='testform]/input[@name='testPasswordField']"
29   *            value="some value"/>
30   * </source></pre>
31   * To use XPath to set a password field named <b>testPasswordField</b> that doesn't exist in a form:
32   * <pre><source>
33   *     &lt;htmlunit-set-password-field
34   *            functionId="Set the testTextField field to 'some value'"
35   *            xpath="//input[@name='testPasswordField']"
36   *            value="some value"/>
37   * </source></pre>
38   * 
39   * To to set a password field named <b>testPasswordField</b> that exists in a form with id or name of <b>form_test</b> w/o using XPath:
40   * <pre><source>
41   *     &lt;htmlunit-set-password-field
42   *            functionId="Set the testTextField field to 'some value'"
43   *            form="form_test"
44   *            fieldName="testPasswordField"
45   *            value="some value"/>
46   * </source></pre>
47   * To to set a password field named <b>testPasswordField</b> that exists in the 2nd form <b>form_test</b> w/o using XPath:
48   * <pre><source>
49   *     &lt;htmlunit-set-password-field
50   *            functionId="Set the testTextField field to 'some value'"
51   *            form="2"
52   *            fieldName="testPasswordField"
53   *            value="some value"/>
54   * </source></pre>
55   * To to set a password field named <b>testPasswordField</b> that exists in form define by <b>//table/tr[3]/td/form</b> XPath:
56   * <pre><source>
57   *     &lt;htmlunit-set-password-field
58   *            functionId="Set the testTextField field to 'some value'"
59   *            form="//table/tr[3]/td/form"
60   *            fieldName="testPasswordField"
61   *            value="some value"/>
62   * </source></pre>
63   * @jameleon.function name="htmlunit-set-password-field" type="action"
64   */
65  public class HtmlUnitSetPasswordFieldTag extends AbstractHtmlUnitSetInputFieldTag{
66  
67      protected String getInputType(){
68          return "password";
69      }
70  
71      protected void setFieldValueInForm(){
72          if (value != null) {
73              setPasswordField(fieldName, value);
74          }
75      }
76  
77  }