1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 * <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 * <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 * <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 * <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 * <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 }