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 table in the current page with the given
08: * id. This table will be used by the check_tablecell.
09: * <br/>
10: * parmater: id of the table
11: * <br/>
12: * examples:
13: * <br/>
14: * select_table | MyTestTable
15: *
16: * @author Mecky
17: */
18: public class SelectTableCommand implements WebTestNode {
19:
20: public static final String COMMAND_NAME = "select_table";
21: private String tableName;
22:
23: public void setParameter(String value) {
24: tableName = value;
25: }
26:
27: public WebTestNodeResult execute(WebTestContext context) {
28: WebTestNodeResult result = new WebTestNodeResult(COMMAND_NAME,
29: tableName);
30: try {
31: context.selectTable(tableName);
32: if (context.getTable() != null) {
33: result.setSuccess(true);
34: } else {
35: result.setSuccess(false);
36: result
37: .setErrorMessage("select_table: no table found for the given ID:"
38: + tableName);
39: }
40: } catch (SAXException e) {
41: result.setSuccess(false);
42: result.setException(e);
43: }
44: return result;
45: }
46:
47: public String getName() {
48: return COMMAND_NAME;
49: }
50:
51: }
|