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 text field to the provided value.
23 * <br/>
24 * To use XPath to set a text field named <b>testTextField</b> that exists in a form with the name <b>testform</b>:
25 * <pre><source>
26 * <htmlunit-set-text-field
27 * functionId="Set the testTextField field to 'some value'"
28 * xpath="//form[@name='testform']/input[@name='testTextField']"
29 * value="some value"/>
30 * </source></pre>
31 * To use XPath to set a text field named <b>testTextField</b> that doesn't exist in a form:
32 * <pre><source>
33 * <htmlunit-set-text-field
34 * functionId="Set the testTextField field to 'some value'"
35 * xpath="//input[@name='testTextField']"
36 * value="some value"/>
37 * </source></pre>
38 * To to set a text field named <b>testTextField</b> that exists in a form with id or name of <b>form_test</b> w/o using XPath:
39 * <pre><source>
40 * <htmlunit-set-text-field
41 * functionId="Set the testTextField field to 'some value'"
42 * form="form_test"
43 * fieldName="testTextField"
44 * value="some value"/>
45 * </source></pre>
46 * To to set a text field named <b>testTextField</b> that exists in the 2nd form <b>form_test</b> w/o using XPath:
47 * <pre><source>
48 * <htmlunit-set-text-field
49 * functionId="Set the testTextField field to 'some value'"
50 * form="2"
51 * fieldName="testTextField"
52 * value="some value"/>
53 * </source></pre>
54 * To to set a text field named <b>testTextField</b> that exists in form define by <b>//table/tr[3]/td/form</b> XPath:
55 * <pre><source>
56 * <htmlunit-set-text-field
57 * functionId="Set the testTextField field to 'some value'"
58 * form="//table/tr[3]/td/form"
59 * fieldName="testTextField"
60 * value="some value"/>
61 * </source></pre>
62 * @jameleon.function name="htmlunit-set-text-field" type="action"
63 */
64 public class HtmlUnitSetTextFieldTag extends AbstractHtmlUnitSetInputFieldTag{
65
66 protected String getInputType(){
67 return "text";
68 }
69
70 protected void setFieldValueInForm(){
71 if (value != null) {
72 setTextField(fieldName, value);
73 }
74 }
75
76 }