01: // Copyright © 2006-2007 ASERT. Released under the Canoo Webtest license.
02: package com.canoo.webtest.plugins.exceltest;
03:
04: import com.canoo.webtest.engine.StepExecutionException;
05:
06: /**
07: * @author Rob Nielsen
08: * @webtest.step category="Excel"
09: * name="excelSelectSheet"
10: * alias="selectSheet"
11: * description="Provides the ability to select the current sheet. Any subsequent calls to excel steps will use the selected sheet if not overridden"
12: */
13: public class ExcelSelectSheet extends AbstractExcelSheetStep {
14: public void doExecute() {
15: setCurrentSheet(getExcelSheet());
16: }
17:
18: /**
19: * @param name The Sheet Name
20: * @webtest.parameter required="yes/no"
21: * description="The name of the sheet to select. Either <em>sheetName</em> or <em>sheetIndex</em> must be selected."
22: */
23: public void setSheetName(final String name) {
24: super .setSheetName(name);
25: }
26:
27: /**
28: * @param index The Sheet Name
29: * @webtest.parameter required="yes/no"
30: * description="The index of the sheet to select, starting at zero. Either <em>sheetName</em> or <em>sheetIndex</em> must be selected."
31: */
32: public void setSheetIndex(final String index) {
33: super .setSheetIndex(index);
34: }
35:
36: protected void verifyParameters() {
37: super .verifyParameters();
38: if (getSheetIndex() == null && getSheetName() == null) {
39: throw new StepExecutionException(
40: "Either sheet number or sheet name should be specified",
41: this );
42: }
43: if (getSheetIndex() != null && getSheetName() != null) {
44: throw new StepExecutionException(
45: "One of sheet number or sheet name must be specified",
46: this);
47: }
48: }
49:
50: }
|