01: // Copyright © 2004-2005 ASERT. Released under the Canoo Webtest license.
02: package com.canoo.webtest.steps.request;
03:
04: import com.canoo.webtest.engine.StepExecutionException;
05: import com.canoo.webtest.self.TestBlock;
06: import com.canoo.webtest.self.ThrowAssert;
07: import com.canoo.webtest.steps.BaseStepTestCase;
08: import com.canoo.webtest.steps.Step;
09:
10: /**
11: * Test class for {@link ClickElementTest}.<p>
12: *
13: * @author Paul King
14: */
15: public class ClickElementTest extends BaseStepTestCase {
16: private ClickElement fStep;
17:
18: private final TestBlock fBlock = new TestBlock() {
19: public void call() throws Exception {
20: executeStep(fStep);
21: }
22: };
23:
24: protected Step createStep() {
25: return new ClickElement();
26: }
27:
28: protected void setUp() throws Exception {
29: super .setUp();
30: fStep = (ClickElement) getStep();
31: }
32:
33: public void testVerifyParameterUsage() {
34: // <clickElement />
35: String message = ThrowAssert.assertThrows(
36: StepExecutionException.class, fBlock);
37: assertEquals("\"htmlId\" or \"xPath\" must be set!", message);
38: // <clickElement htmlId="X" xPath="Y" />
39: fStep.setHtmlId("X");
40: fStep.setXpath("Y");
41: message = ThrowAssert.assertThrows(
42: StepExecutionException.class, fBlock);
43: assertEquals(
44: "Only one from \"htmlId\" and \"xPath\" can be set!",
45: message);
46: }
47:
48: public void testVerifyParametersWithoutPreviousPage() {
49: fStep.setHtmlId("someId");
50: assertStepRejectsNullResponse(fStep);
51: }
52: }
|