01: package com.canoo.webtest.extension.dialogs;
02:
03: import com.canoo.webtest.steps.verify.AbstractVerifyTextStep;
04: import com.canoo.webtest.engine.StepFailedException;
05:
06: public abstract class AbstractDialogStep extends AbstractVerifyTextStep {
07: private String fResponse;
08: private String fSaveProperty;
09: private String fSavePropertyType;
10:
11: protected AbstractDialogStep() {
12: super ();
13: }
14:
15: protected AbstractDialogStep(final String response,
16: final String text, final String regex,
17: final String saveProperty, final String savePropertyType) {
18: setRegex(regex);
19: setText(text);
20: this .fResponse = response;
21: this .fSaveProperty = saveProperty;
22: this .fSavePropertyType = savePropertyType;
23: }
24:
25: /**
26: * The name of the property used to save dialog text.
27: *
28: * @param value The new saveProperty value
29: * @webtest.parameter required="no"
30: * description="The name of the property in which to store the dialog text for later checking with \"verifyProperty\". Must not be set if <em>text</em> is also set."
31: */
32: public void setSaveProperty(final String value) {
33: fSaveProperty = value;
34: }
35:
36: public String getSaveProperty() {
37: return fSaveProperty;
38: }
39:
40: /**
41: * The type of the property used to save dialog text ("ant" or "dynamic").
42: *
43: * @param value The new savePropertyType value
44: * @webtest.parameter required="no"
45: * description="The type of the property in which to store the dialog text for later checking. Either \"ant\" or \"dynamic\". Ignored if <em>saveProperty</em> is not set."
46: * default="the \"defaultPropertyType\" as specified in the \"config\" element is used."
47: */
48: public void setSavePropertyType(final String value) {
49: fSavePropertyType = value;
50: }
51:
52: public String getSavePropertyType() {
53: return fSavePropertyType;
54: }
55:
56: /**
57: * The response value returned to the JavaScript
58: *
59: * @param value The new response value
60: * @webtest.parameter required="no"
61: * description="simulate user response: ignored for alerts; converted to boolean for confirms - \"OK\" (true) or \"Cancel\" (false); contains typed text for prompts."
62: * default="true"
63: */
64: public void setResponse(final String value) {
65: fResponse = value;
66: }
67:
68: public String getResponse() {
69: return fResponse;
70: }
71:
72: public void verify(final String actual) {
73: if (getText() != null && !super .verifyText(actual)) {
74: throw new StepFailedException(
75: "Wrong dialog message found! [Regex=" + isRegex()
76: + "]", getText(), actual, this);
77: }
78: }
79: }
|