<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- Copyright 2004 ThoughtWorks, Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JsUnit Utility Tests</title> <link rel="stylesheet" type="text/css" href="../../jsunit/css/jsUnitStyle.css"> <script language="JavaScript" type="text/javascript" src="../../jsunit/app/jsUnitCore.js"></script> <script language="JavaScript" type="text/javascript" src="../jsmock/mock.js"></script> <script language="JavaScript" type="text/javascript" src="../dummy-logging.js"></script> <script language="JavaScript" type="text/javascript" src="../../core/lib/prototype.js"></script> <script language="JavaScript" type="text/javascript" src="../../core/scripts/htmlutils.js"></script> <script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-browserdetect.js"></script> <script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-browserbot.js"></script> <script language="JavaScript" type="text/javascript"> function setUp() { $("body").innerHTML = "<iframe NAME='frame' ID='frame' SRC='about:blank'></iframe>" testWindow = window; browserBot = BrowserBot.createForWindow(testWindow); browserBot.getCurrentPage(); } function testShouldConfirmConfirmationsByDefault() { assertTrue(testWindow.confirm("Continue?")); } function testShouldCancelConfirmationIfPreviouslyInstructedTo() { browserBot.cancelNextConfirmation(false); assertFalse(testWindow.confirm("Continue?")); } function testShouldRevertToDefaultBehaviourAfterCancellingConfirmation() { browserBot.cancelNextConfirmation(false); testWindow.confirm("Continue?"); testShouldConfirmConfirmationsByDefault(); } function testShouldNotReportAnyConfirmationsIfNoneHaveBeenGenerated() { assertFalse(browserBot.hasConfirmations()); assertUndefined(browserBot.getNextConfirmation()); } function testShouldReportSingleConfirmationIfGenerated() { testWindow.confirm("Continue?"); assertTrue(browserBot.hasConfirmations()); assertEquals("Continue?", browserBot.getNextConfirmation()); } function testShouldReportMultipleConfirmationsInOrderIfGenerated() { testWindow.confirm("Continue?"); testWindow.confirm("Really Continue?"); assertTrue(browserBot.hasConfirmations()); assertEquals("Continue?", browserBot.getNextConfirmation()); assertTrue(browserBot.hasConfirmations()); assertEquals("Really Continue?", browserBot.getNextConfirmation()); assertFalse(browserBot.hasConfirmations()); } function testShouldRemoveConfirmationWhenItIsRetreived() { testWindow.confirm("Continue?"); assertTrue(browserBot.hasConfirmations()); assertNotUndefined(browserBot.getNextConfirmation()); assertFalse(browserBot.hasConfirmations()); assertUndefined(browserBot.getNextConfirmation()); } </script> </head> <body id="body"> <h1>Selenium PageBot Confirm Handling Tests</h1> </body> </html>