01: package org.jzonic.webtester.commands;
02:
03: import org.jzonic.webtester.WebTestContext;
04: import org.xml.sax.SAXException;
05:
06: /**
07: * This command will select a form fom the current page. The index is
08: * zero based. This form is saved in the WebTestContext and will be used
09: * by all commands referring to forms.
10: * <br/>
11: * parameter: zero based number of the form
12: * <br/>
13: * examples:
14: * <br/>
15: * select_form | 0
16: *
17: * @author Mecky
18: */
19: public class SelectFormCommand implements WebTestNode {
20:
21: public static final String COMMAND_NAME = "select_form";
22: private int formNumber = -1;
23:
24: public void setParameter(String value) {
25: formNumber = Integer.parseInt(value);
26: }
27:
28: public WebTestNodeResult execute(WebTestContext context) {
29: WebTestNodeResult result = new WebTestNodeResult(COMMAND_NAME,
30: String.valueOf(formNumber));
31: try {
32: context.selectForm(formNumber);
33: result.setSuccess(true);
34: } catch (SAXException e) {
35: result.setSuccess(false);
36: result.setException(e);
37: }
38: return result;
39: }
40:
41: public String getName() {
42: return COMMAND_NAME;
43: }
44:
45: }
|