01: // Copyright © 2004-2005 ASERT. Released under the Canoo Webtest license.
02: package com.canoo.webtest.extension.dialogs;
03:
04: import com.canoo.webtest.engine.StepFailedException;
05: import com.canoo.webtest.steps.Step;
06: import org.apache.log4j.Logger;
07:
08: /**
09: * Check that all expected dialogs have been 'consumed' by JavaScript.<p>
10: *
11: * @author Paul King
12: * @webtest.step category="Extension"
13: * name="verifyNoDialogs"
14: * alias="verifyNoDialogResponses"
15: * description="Used in conjunction with the <stepref name='expectDialog' category='Extension'/> and <stepref name='expectDialogs' category='Extension'/> steps when dealing with <key>javascript</key> Dialog boxes. This step checks that all user responses expected were in fact \"consumed\" by <key>javascript</key>."
16: */
17: public class VerifyNoDialogs extends Step {
18: private static final Logger LOG = Logger
19: .getLogger(VerifyNoDialogs.class);
20:
21: public void doExecute() {
22: final int count = DialogHelper
23: .getExpectedDialogsCount(getContext());
24: LOG.debug("Number of expected dialogs = " + count);
25: if (count > 0) {
26: throw new StepFailedException(
27: "Dialogs found but none expected!", this);
28: }
29: }
30:
31: }
|