rubinium 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/CHANGES +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +137 -0
  4. data/Rakefile +139 -0
  5. data/TODO +7 -0
  6. data/doc/examples/rtc_site_live.rb +12 -0
  7. data/doc/examples/rts_main.rb +9 -0
  8. data/doc/examples/rts_shared_code.rb +25 -0
  9. data/lib/rubinium.rb +9 -0
  10. data/lib/rubinium/string.rb +3 -0
  11. data/lib/rubinium/test_base.rb +80 -0
  12. data/lib/rubinium/test_suite.rb +53 -0
  13. data/lib/rubinium/validator.rb +16 -0
  14. data/test/selenium_tests/test_click.rb +22 -0
  15. data/test/selenium_tests/test_open.rb +11 -0
  16. data/test/tc_file_creation.rb +60 -0
  17. data/test/ts_rubinium.rb +1 -0
  18. data/vendor/selenium-0.6.0/install-readme.txt +9 -0
  19. data/vendor/selenium-0.6.0/selenium/SeleneseRunner.html +253 -0
  20. data/vendor/selenium-0.6.0/selenium/SeleniumLog.html +61 -0
  21. data/vendor/selenium-0.6.0/selenium/TestRunner-splash.html +55 -0
  22. data/vendor/selenium-0.6.0/selenium/TestRunner.hta +146 -0
  23. data/vendor/selenium-0.6.0/selenium/TestRunner.html +146 -0
  24. data/vendor/selenium-0.6.0/selenium/devtests/TestClickInFrame.html +58 -0
  25. data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInFrame.html +48 -0
  26. data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInNewWindow.html +78 -0
  27. data/vendor/selenium-0.6.0/selenium/devtests/TestOpenMeta.html +43 -0
  28. data/vendor/selenium-0.6.0/selenium/devtests/TestSuite.html +39 -0
  29. data/vendor/selenium-0.6.0/selenium/devtests/meta/page.html +5 -0
  30. data/vendor/selenium-0.6.0/selenium/dom-images/butmin.gif +0 -0
  31. data/vendor/selenium-0.6.0/selenium/dom-images/butplus.gif +0 -0
  32. data/vendor/selenium-0.6.0/selenium/dom-styles/default.css +298 -0
  33. data/vendor/selenium-0.6.0/selenium/domviewer.html +16 -0
  34. data/vendor/selenium-0.6.0/selenium/html-xpath/carnation.jpg +0 -0
  35. data/vendor/selenium-0.6.0/selenium/html-xpath/example.html +75 -0
  36. data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath-patched.js +657 -0
  37. data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath.js +610 -0
  38. data/vendor/selenium-0.6.0/selenium/html-xpath/license.txt +504 -0
  39. data/vendor/selenium-0.6.0/selenium/html-xpath/rainbow.jpg +0 -0
  40. data/vendor/selenium-0.6.0/selenium/htmlutils.js +283 -0
  41. data/vendor/selenium-0.6.0/selenium/index.html +60 -0
  42. data/vendor/selenium-0.6.0/selenium/jsmock/mock-tests.html +205 -0
  43. data/vendor/selenium-0.6.0/selenium/jsmock/mock.js +124 -0
  44. data/vendor/selenium-0.6.0/selenium/selenium-api.js +683 -0
  45. data/vendor/selenium-0.6.0/selenium/selenium-browserbot.js +930 -0
  46. data/vendor/selenium-0.6.0/selenium/selenium-commandhandlers.js +286 -0
  47. data/vendor/selenium-0.6.0/selenium/selenium-domviewer.js +188 -0
  48. data/vendor/selenium-0.6.0/selenium/selenium-executionloop.js +250 -0
  49. data/vendor/selenium-0.6.0/selenium/selenium-fitrunner.js +597 -0
  50. data/vendor/selenium-0.6.0/selenium/selenium-logging.js +88 -0
  51. data/vendor/selenium-0.6.0/selenium/selenium-logo.png +0 -0
  52. data/vendor/selenium-0.6.0/selenium/selenium-tableparser.js +50 -0
  53. data/vendor/selenium-0.6.0/selenium/selenium.css +211 -0
  54. data/vendor/selenium-0.6.0/selenium/tests/ErrorCheckingTestSuite.html +36 -0
  55. data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSearch.html +69 -0
  56. data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSuite.html +32 -0
  57. data/vendor/selenium-0.6.0/selenium/tests/JsUnitSuite.html +38 -0
  58. data/vendor/selenium-0.6.0/selenium/tests/TestClick.html +128 -0
  59. data/vendor/selenium-0.6.0/selenium/tests/TestClickJavascriptHref.html +115 -0
  60. data/vendor/selenium-0.6.0/selenium/tests/TestCommandError.html +79 -0
  61. data/vendor/selenium-0.6.0/selenium/tests/TestConfirmations.html +77 -0
  62. data/vendor/selenium-0.6.0/selenium/tests/TestErrorChecking.html +71 -0
  63. data/vendor/selenium-0.6.0/selenium/tests/TestFailingAssert.html +59 -0
  64. data/vendor/selenium-0.6.0/selenium/tests/TestFailingVerifications.html +198 -0
  65. data/vendor/selenium-0.6.0/selenium/tests/TestFocusOnBlur.html +53 -0
  66. data/vendor/selenium-0.6.0/selenium/tests/TestGoBack.html +81 -0
  67. data/vendor/selenium-0.6.0/selenium/tests/TestImplicitLocators.html +81 -0
  68. data/vendor/selenium-0.6.0/selenium/tests/TestJavascriptParameters.html +91 -0
  69. data/vendor/selenium-0.6.0/selenium/tests/TestLocators.html +161 -0
  70. data/vendor/selenium-0.6.0/selenium/tests/TestModalDialog.html +58 -0
  71. data/vendor/selenium-0.6.0/selenium/tests/TestModalDialogDialog.html +48 -0
  72. data/vendor/selenium-0.6.0/selenium/tests/TestOpen.html +66 -0
  73. data/vendor/selenium-0.6.0/selenium/tests/TestPatternMatching.html +127 -0
  74. data/vendor/selenium-0.6.0/selenium/tests/TestPause.html +78 -0
  75. data/vendor/selenium-0.6.0/selenium/tests/TestPrompting.html +82 -0
  76. data/vendor/selenium-0.6.0/selenium/tests/TestProxy.html +62 -0
  77. data/vendor/selenium-0.6.0/selenium/tests/TestSelect.html +111 -0
  78. data/vendor/selenium-0.6.0/selenium/tests/TestSelectWindow.html +106 -0
  79. data/vendor/selenium-0.6.0/selenium/tests/TestStore.html +165 -0
  80. data/vendor/selenium-0.6.0/selenium/tests/TestSuite-InternetExplorer.html +79 -0
  81. data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Konqueror.html +75 -0
  82. data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Safari.html +75 -0
  83. data/vendor/selenium-0.6.0/selenium/tests/TestSuite.html +75 -0
  84. data/vendor/selenium-0.6.0/selenium/tests/TestType.html +79 -0
  85. data/vendor/selenium-0.6.0/selenium/tests/TestUserExtensions.html +81 -0
  86. data/vendor/selenium-0.6.0/selenium/tests/TestVerifications.html +164 -0
  87. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlerts.html +80 -0
  88. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlertsFailures.html +108 -0
  89. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyConfirmationFailures.html +86 -0
  90. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditable.html +70 -0
  91. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditableFailures.html +95 -0
  92. data/vendor/selenium-0.6.0/selenium/tests/TestVisibility.html +91 -0
  93. data/vendor/selenium-0.6.0/selenium/tests/TestVisibilityFailures.html +131 -0
  94. data/vendor/selenium-0.6.0/selenium/tests/TestWait.html +112 -0
  95. data/vendor/selenium-0.6.0/selenium/tests/TestWaitFor.html +63 -0
  96. data/vendor/selenium-0.6.0/selenium/tests/TestWaitInPopupWindow.html +94 -0
  97. data/vendor/selenium-0.6.0/selenium/tests/TestXPathLocators.html +98 -0
  98. data/vendor/selenium-0.6.0/selenium/tests/browserbot/alert-handling-tests.html +79 -0
  99. data/vendor/selenium-0.6.0/selenium/tests/browserbot/assert-tests.html +113 -0
  100. data/vendor/selenium-0.6.0/selenium/tests/browserbot/browserbot-tests.html +123 -0
  101. data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-factory-tests.html +290 -0
  102. data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-handler-tests.html +115 -0
  103. data/vendor/selenium-0.6.0/selenium/tests/browserbot/confirm-handling-tests.html +97 -0
  104. data/vendor/selenium-0.6.0/selenium/tests/browserbot/error-checking-command-tests.html +198 -0
  105. data/vendor/selenium-0.6.0/selenium/tests/browserbot/event-bubble-tests.html +106 -0
  106. data/vendor/selenium-0.6.0/selenium/tests/browserbot/optionlocator-tests.html +180 -0
  107. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-accessor-tests.html +65 -0
  108. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-action-tests.html +200 -0
  109. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-attribute-tests.html +98 -0
  110. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests-include.html +33 -0
  111. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests.html +258 -0
  112. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-property-tests.html +49 -0
  113. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pattern-matcher-tests.html +66 -0
  114. data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-api-tests.html +412 -0
  115. data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-parameter-tests.html +98 -0
  116. data/vendor/selenium-0.6.0/selenium/tests/browserbot/suite.html +52 -0
  117. data/vendor/selenium-0.6.0/selenium/tests/browserbot/testloop-handle-error-tests.html +74 -0
  118. data/vendor/selenium-0.6.0/selenium/tests/events/TestButtonEvents.html +72 -0
  119. data/vendor/selenium-0.6.0/selenium/tests/events/TestCheckboxEvents.html +107 -0
  120. data/vendor/selenium-0.6.0/selenium/tests/events/TestFireEvents.html +75 -0
  121. data/vendor/selenium-0.6.0/selenium/tests/events/TestLinkEvents.html +43 -0
  122. data/vendor/selenium-0.6.0/selenium/tests/events/TestRadioEvents.html +149 -0
  123. data/vendor/selenium-0.6.0/selenium/tests/events/TestSelectEvents.html +122 -0
  124. data/vendor/selenium-0.6.0/selenium/tests/events/TestTextEvents.html +87 -0
  125. data/vendor/selenium-0.6.0/selenium/tests/events/readme.txt +26 -0
  126. data/vendor/selenium-0.6.0/selenium/tests/html/banner.gif +0 -0
  127. data/vendor/selenium-0.6.0/selenium/tests/html/test_async_event.html +36 -0
  128. data/vendor/selenium-0.6.0/selenium/tests/html/test_click_javascript_page.html +34 -0
  129. data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page1.html +31 -0
  130. data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page2.html +30 -0
  131. data/vendor/selenium-0.6.0/selenium/tests/html/test_confirm.html +34 -0
  132. data/vendor/selenium-0.6.0/selenium/tests/html/test_dummy_page.html +26 -0
  133. data/vendor/selenium-0.6.0/selenium/tests/html/test_editable.html +36 -0
  134. data/vendor/selenium-0.6.0/selenium/tests/html/test_focus_on_blur.html +33 -0
  135. data/vendor/selenium-0.6.0/selenium/tests/html/test_form_events.html +98 -0
  136. data/vendor/selenium-0.6.0/selenium/tests/html/test_framed_page.html +7 -0
  137. data/vendor/selenium-0.6.0/selenium/tests/html/test_just_text.html +22 -0
  138. data/vendor/selenium-0.6.0/selenium/tests/html/test_locators.html +34 -0
  139. data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog.html +29 -0
  140. data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog_dialog.html +35 -0
  141. data/vendor/selenium-0.6.0/selenium/tests/html/test_open.html +23 -0
  142. data/vendor/selenium-0.6.0/selenium/tests/html/test_prompt.html +34 -0
  143. data/vendor/selenium-0.6.0/selenium/tests/html/test_reload_onchange_page.html +32 -0
  144. data/vendor/selenium-0.6.0/selenium/tests/html/test_select.html +35 -0
  145. data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window.html +29 -0
  146. data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window_popup.html +28 -0
  147. data/vendor/selenium-0.6.0/selenium/tests/html/test_slowloading_page.html +27 -0
  148. data/vendor/selenium-0.6.0/selenium/tests/html/test_store_value.html +23 -0
  149. data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page1.html +37 -0
  150. data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page2.html +61 -0
  151. data/vendor/selenium-0.6.0/selenium/tests/html/test_verifications.html +42 -0
  152. data/vendor/selenium-0.6.0/selenium/tests/html/test_verify_alert.html +46 -0
  153. data/vendor/selenium-0.6.0/selenium/tests/html/test_visibility.html +53 -0
  154. data/vendor/selenium-0.6.0/selenium/tests/readme.txt +1 -0
  155. data/vendor/selenium-0.6.0/selenium/tests/tableparser/tableparser-tests.html +122 -0
  156. data/vendor/selenium-0.6.0/selenium/tests/tinyWebServer.py +70 -0
  157. data/vendor/selenium-0.6.0/selenium/user-extensions.js.sample +62 -0
  158. data/vendor/selenium-0.6.0/selenium/version.txt +1 -0
  159. data/vendor/selenium-0.6.0/selenium/xmlextras.js +153 -0
  160. data/vendor/selenium-0.6.0/selenium/xpath.js +3910 -0
  161. metadata +216 -0
@@ -0,0 +1,79 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <!--
4
+ Copyright 2004 ThoughtWorks, Inc
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ -->
18
+ <html>
19
+ <head>
20
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
21
+ <title>JsUnit Utility Tests</title>
22
+ <link rel="stylesheet" type="text/css" href="/jsunit/css/jsUnitStyle.css">
23
+ <script language="JavaScript" type="text/javascript" src="/jsunit/app/jsUnitCore.js"></script>
24
+ <script language="JavaScript" type="text/javascript" src="/jsmock/mock.js"></script>
25
+ <script language="JavaScript" type="text/javascript" src="/selenium-logging.js"></script>
26
+ <script language="JavaScript" type="text/javascript" src="/selenium-browserbot.js"></script>
27
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
28
+ <script language="JavaScript" type="text/javascript">
29
+
30
+ function setUp() {
31
+ LOG = new DummyLogger();
32
+ testFrame = document.getElementById("frame");
33
+ testWindow = testFrame.contentWindow;
34
+ browserBot = BrowserBot.createForFrame(testFrame);
35
+ browserBot.getCurrentPage();
36
+ }
37
+
38
+ function testShouldNotReportAnyAlertsIfNoneHaveBeenGenerated() {
39
+ assertFalse(browserBot.hasAlerts());
40
+ assertUndefined(browserBot.getNextAlert());
41
+ }
42
+
43
+ function testShouldReportSingleAlertIfGenerated() {
44
+ testWindow.alert("Be Alert, Not Alarmed");
45
+
46
+ assertTrue(browserBot.hasAlerts());
47
+ assertEquals("Be Alert, Not Alarmed", browserBot.getNextAlert());
48
+ }
49
+
50
+ function testShouldReportMultipleAlertsInOrderIfGenerated() {
51
+ testWindow.alert("Warning: unfunny joke ahead");
52
+ testWindow.alert("Be Alert, We need more Lerts");
53
+
54
+ assertTrue(browserBot.hasAlerts());
55
+ assertEquals("Warning: unfunny joke ahead", browserBot.getNextAlert());
56
+ assertTrue(browserBot.hasAlerts());
57
+ assertEquals("Be Alert, We need more Lerts", browserBot.getNextAlert());
58
+ assertFalse(browserBot.hasAlerts());
59
+ }
60
+
61
+ function testShouldRemoveAlertWhenItIsRetreived() {
62
+ testWindow.alert("Be Alert, Not Alarmed");
63
+
64
+ assertTrue(browserBot.hasAlerts());
65
+ assertNotUndefined(browserBot.getNextAlert());
66
+ assertFalse(browserBot.hasAlerts());
67
+ assertUndefined(browserBot.getNextAlert());
68
+ }
69
+
70
+
71
+ </script>
72
+ </head>
73
+
74
+ <body>
75
+ <h1>Selenium PageBot Alert Handling Tests</h1>
76
+ <iframe NAME="frame" ID="frame" SRC=""></iframe>
77
+
78
+ </body>
79
+ </html>
@@ -0,0 +1,113 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+
4
+ <!--
5
+ Copyright 2004 ThoughtWorks, Inc
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -->
19
+ <html>
20
+ <head>
21
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
22
+ <title>Assert tests</title>
23
+ <link rel="stylesheet" type="text/css" href="/jsunit/css/jsUnitStyle.css">
24
+ <script language="JavaScript" type="text/javascript" src="/jsunit/app/jsUnitCore.js"></script>
25
+ <script language="JavaScript" type="text/javascript" src="/jsmock/mock.js"></script>
26
+
27
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
28
+ <script language="JavaScript" type="text/javascript" src="/selenium-executionloop.js"></script>
29
+ <script language="JavaScript" type="text/javascript" src="/selenium-api.js"></script>
30
+ <script language="JavaScript" type="text/javascript">
31
+
32
+ function testAssertEqalsDoesntThrowExceptionWhenMatches() {
33
+ Assert.equals("foo", "foo");
34
+ }
35
+
36
+ function testAssertEqualsThrowsExceptionWhenNotMatches() {
37
+ try {
38
+ Assert.equals("foo", "fox");
39
+ }
40
+ catch (e) {
41
+ assertEquals("Expected 'foo' but was 'fox'", e.failureMessage);
42
+ return;
43
+ }
44
+ fail("Should have thrown exception");
45
+ }
46
+
47
+ function testAssertEqualsCanIncludeAComment() {
48
+ try {
49
+ Assert.equals("testComment", "foo", "fox");
50
+ }
51
+ catch (e) {
52
+ assertEquals("testComment; Expected 'foo' but was 'fox'", e.failureMessage);
53
+ return;
54
+ }
55
+ fail("Should have thrown exception");
56
+ }
57
+
58
+ function testAssertMatchesDoesntThrowExceptionWhenMatches() {
59
+ Assert.matches("regexp:fo[aeiou]", "foo");
60
+ }
61
+
62
+ function testAssertMatchesThrowsExceptionWhenNotMatches() {
63
+ try {
64
+ Assert.matches("regexp:fo[aei]", "foo");
65
+ }
66
+ catch (e) {
67
+ assertEquals("Actual value 'foo' did not match 'regexp:fo[aei]'", e.failureMessage);
68
+ return;
69
+ }
70
+ fail("Should have thrown exception");
71
+ }
72
+
73
+ function testPatternMatchesCanIncludeComment() {
74
+ try {
75
+ Assert.matches("TestComment", "regexp:fo[aei]", "foo");
76
+ assertEquals("TestComment; Actual value 'foo' did not match 'regexp:fo[aei]'", e.failureMessage);
77
+ }
78
+ catch (e) {
79
+ return;
80
+ }
81
+ fail("Should have thrown exception");
82
+ }
83
+
84
+ function testAssertNotMatchesDoesntThrowExceptionWhenNotMatches() {
85
+ Assert.notMatches("regexp:fo[aeiou]", "fox");
86
+ }
87
+
88
+ function testAssertNotMatchesThrowsExceptionWhenMatches() {
89
+ try {
90
+ Assert.notMatches("regexp:fo[aeix]", "fox");
91
+ }
92
+ catch (e) {
93
+ assertEquals("Actual value 'fox' did match 'regexp:fo[aeix]'", e.failureMessage);
94
+ return;
95
+ }
96
+ fail("Should have thrown exception");
97
+ }
98
+
99
+ function testAssertNotMatchesCanIncludeComment() {
100
+ try {
101
+ Assert.notMatches("TestComment", "regexp:fo[aeix]", "fox");
102
+ }
103
+ catch (e) {
104
+ assertEquals("TestComment; Actual value 'fox' did match 'regexp:fo[aeix]'", e.failureMessage);
105
+ return;
106
+ }
107
+ fail("Should have thrown exception");
108
+ }
109
+
110
+ </script>
111
+ </head>
112
+ <body>Assert Tests</body>
113
+ </html>s
@@ -0,0 +1,123 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+
4
+ <!--
5
+ Copyright 2004 ThoughtWorks, Inc
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -->
19
+ <html>
20
+ <head>
21
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
22
+ <title>BrowserBot tests</title>
23
+ <link rel="stylesheet" type="text/css" href="/jsunit/css/jsUnitStyle.css">
24
+ <script language="JavaScript" type="text/javascript" src="/jsunit/app/jsUnitCore.js"></script>
25
+ <script language="JavaScript" type="text/javascript" src="/jsmock/mock.js"></script>
26
+
27
+ <script language="JavaScript" type="text/javascript" src="/selenium-browserbot.js"></script>
28
+ <script language="JavaScript" type="text/javascript" src="/selenium-logging.js"></script>
29
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
30
+ <script language="JavaScript" type="text/javascript">
31
+ function setUp() {
32
+ LOG = new DummyLogger();
33
+ mockFrame = new String('mockFrame');
34
+
35
+ mockFrame.contentWindow = new String('mockContentWindow');
36
+ mockFrame.contentWindow.window = new String('mockWindow');
37
+
38
+ browserBot = new MozillaBrowserBot(mockFrame);
39
+
40
+ browserBot.currentWindowName = 'originalWindowName';
41
+ browserBot.currentPage = 'originalPage';
42
+ }
43
+
44
+ function testPageAndCurrentWindowNameIsSetToNullWhenSelectWindowIsCalledWithNull() {
45
+ browserBot.selectWindow('null');
46
+
47
+ assertNull(browserBot.currentPage);
48
+ assertNull(browserBot.currentWindowName);
49
+ }
50
+
51
+ function testPageIsSetToNullAndCurrentWindowIsSetWhenSelectWindowIsCalledWithNonNull() {
52
+ // Make sure new window can be found
53
+ mockFrame.contentWindow.window.windowName = new String('anotherWindow');
54
+
55
+ browserBot.selectWindow('windowName');
56
+
57
+ assertNull(browserBot.currentPage);
58
+ assertEquals('windowName', browserBot.currentWindowName);
59
+ }
60
+
61
+ function testExceptionWhenSelectWindowIsCalledWithUnknownWindowName() {
62
+ try {
63
+ browserBot.selectWindow('notAwindow');
64
+ fail("Should have thrown exception");
65
+ }
66
+ catch (e) {
67
+ assertEquals("Window does not exist", e.message);
68
+ }
69
+ }
70
+
71
+ function testCurrentPageIsNullAndFrameSrcIsSetOnOpenLocation() {
72
+ browserBot.openLocation('myNewLocation');
73
+
74
+ assertNull(browserBot.currentPage);
75
+ assertEquals('myNewLocation', mockFrame.src);
76
+ }
77
+
78
+ function testCurrentPageIsLazyCreatedBasedOnContentWindowWhenCurrentWindowNameIsNull() {
79
+ browserBot.currentWindowName = null;
80
+ browserBot.currentPage = null;
81
+
82
+ var mockLocation = new Mock();
83
+ mockLocation.expectsProperty('pathname').returns('thelocation');
84
+
85
+ mockFrame.contentWindow.window.location = mockLocation;
86
+ mockFrame.contentWindow.window.document = 'thedocument';
87
+ mockFrame.contentWindow.window.addEventListener = function(){};
88
+ mockFrame.contentWindow.window.attachEvent = function(){};
89
+
90
+ var pageBot = browserBot.getCurrentPage();
91
+ assertEquals(pageBot, browserBot.currentPage);
92
+
93
+ assertEquals(mockFrame.contentWindow.window, pageBot.currentWindow);
94
+ assertEquals('thedocument', pageBot.currentDocument);
95
+ assertEquals(mockLocation, pageBot.location);
96
+
97
+ mockLocation.verify();
98
+ }
99
+
100
+ function testCurrentPageIsLazyCreatedBasedOnNamedWindowWhenCurrentWindowNameIsSet() {
101
+ browserBot.currentPage = null;
102
+
103
+ var mockLocation = new Mock();
104
+ mockLocation.expectsProperty('pathname').returns('thelocation');
105
+
106
+ targetWindow = new String('anotherWindow');
107
+ targetWindow.location = mockLocation;
108
+ targetWindow.addEventListener = function(){};
109
+ targetWindow.attachEvent = function(){};
110
+
111
+ mockFrame.contentWindow.window.targetWindow = targetWindow;
112
+
113
+ browserBot.currentWindowName = 'targetWindow';
114
+
115
+ var pageBot = browserBot.getCurrentPage();
116
+ assertEquals(targetWindow, pageBot.currentWindow);
117
+
118
+ mockLocation.verify();
119
+ }
120
+ </script>
121
+ </head>
122
+ <body>Selenium BrowserBot Tests</body>
123
+ </html>
@@ -0,0 +1,290 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+
4
+ <!--
5
+ Copyright 2004 ThoughtWorks, Inc
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -->
19
+ <html>
20
+ <head>
21
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
22
+ <title>JsUnit Utility Tests</title>
23
+ <link rel="stylesheet" type="text/css" href="jsunit/css/jsUnitStyle.css">
24
+ <script language="JavaScript" type="text/javascript" src="/jsunit/app/jsUnitCore.js"></script>
25
+ <script language="JavaScript" type="text/javascript" src="/jsmock/mock.js"></script>
26
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
27
+ <script language="JavaScript" type="text/javascript" src="/selenium-logging.js"></script>
28
+ <script language="JavaScript" type="text/javascript" src="/selenium-commandhandlers.js"></script>
29
+ <script language="JavaScript" type="text/javascript">
30
+
31
+ function setUp() {
32
+ LOG = new DummyLogger();
33
+ }
34
+
35
+ function testNullIsReturnedForUnknownCommands() {
36
+ var factory = new CommandHandlerFactory();
37
+ assertNull(factory.getCommandHandler("unknown"));
38
+ }
39
+
40
+ function testActionsAreTypedAndAvailableAfterRegistrationInCommandHandlerFactory() {
41
+ var factory = new CommandHandlerFactory();
42
+ factory.registerAction("myAction", "actionFunction");
43
+
44
+ var myAction = factory.getCommandHandler("myAction");
45
+ assertNotNull(myAction);
46
+ assertEquals(CommandHandler, myAction.constructor);
47
+ assertEquals("actionFunction", myAction.executor);
48
+ assertEquals("action", myAction.type);
49
+ }
50
+
51
+ function testAssertsAreTypedAndAvailableAfterRegistrationInCommandHandlerFactory() {
52
+ var factory = new CommandHandlerFactory();
53
+ factory.registerAssert("assertFoo", "assertFunction", true);
54
+
55
+ var myAssert = factory.getCommandHandler("assertFoo");
56
+ assertNotNull(myAssert);
57
+ assertEquals(CommandHandler, myAssert.constructor);
58
+ assertEquals("assertFunction", myAssert.executor);
59
+ assertEquals("assert", myAssert.type);
60
+ assertTrue(myAssert.haltOnFailure);
61
+ }
62
+
63
+ function testAccessorsAreTypedAndAvailableAfterRegistrationInCommandHandlerFactory() {
64
+ var factory = new CommandHandlerFactory();
65
+ factory.registerAccessor("getFoo", "accessorFunction");
66
+
67
+ var myAccessor = factory.getCommandHandler("getFoo");
68
+ assertNotNull(myAccessor);
69
+ assertEquals(CommandHandler, myAccessor.constructor);
70
+ assertEquals("accessorFunction", myAccessor.executor);
71
+ assertEquals("accessor", myAccessor.type);
72
+ }
73
+
74
+ function testCreateMatcherHandlerFromSingleArgAccessorReturnsMatcherHandler() {
75
+ var factory = new CommandHandlerFactory();
76
+ var accessor = function(arg) {
77
+ assertEquals("target", arg);
78
+ return this.foo();
79
+ };
80
+ var matcherHandler = factory.createMatcherHandlerFromSingleArgAccessor(accessor);
81
+ var seleniumApi = {foo: function() { return "theValue";}};
82
+
83
+ var command = new SeleniumCommand(null, "target", "regexp:theV[aeiou]lue");
84
+ var result = matcherHandler(seleniumApi, command);
85
+ assertEquals("Actual value 'theValue' did match 'regexp:theV[aeiou]lue'", result.message);
86
+ assertTrue("Should have matched", result.didMatch);
87
+
88
+ command = new SeleniumCommand(null, "target", "betterNotMatch");
89
+ var result = matcherHandler(seleniumApi, command);
90
+ assertEquals("Actual value 'theValue' did not match 'betterNotMatch'", result.message);
91
+ assertFalse("Should not have matched", result.didMatch);
92
+ }
93
+
94
+ function testCreateMatcherHandlerFromNoArgAccessorReturnsMatcherHandler() {
95
+ var factory = new CommandHandlerFactory();
96
+ var accessor = function() {
97
+ return this.foo();
98
+ };
99
+ var matcherHandler = factory.createMatcherHandlerFromNoArgAccessor(accessor);
100
+ var seleniumApi = {foo: function() { return "theValue";}};
101
+
102
+ var command = new SeleniumCommand(null, "theV*e", "");
103
+ var result = matcherHandler(seleniumApi, command);
104
+ assertEquals("Actual value 'theValue' did match 'theV*e'", result.message);
105
+ assertTrue("Should have matched", result.didMatch);
106
+
107
+ command = new SeleniumCommand(null, "betterNotMatch", "");
108
+ var result = matcherHandler(seleniumApi, command);
109
+ assertEquals("Actual value 'theValue' did not match 'betterNotMatch'", result.message);
110
+ assertFalse("Should not have matched", result.didMatch);
111
+ }
112
+
113
+ function testNegateMatcherHandlerNegatesResult() {
114
+ var factory = new CommandHandlerFactory();
115
+ var matcherHandler = function(seleniumApi, command) {return new MatcherHandlerResult(true, "msg");};
116
+ var negatedMatcherHandler = factory.createMatcherHandlerNegator(matcherHandler);
117
+ var result = negatedMatcherHandler("seleniumApi", "command");
118
+ assertFalse("Result should have been negated", result.didMatch);
119
+ assertEquals("msg", result.message);
120
+ }
121
+
122
+ function testAssertUsingMatcherHandlerWithPositiveResultDoesNotThrowExceptions() {
123
+ var mockMatcherHandlerResult = new Mock();
124
+ mockMatcherHandlerResult.expectsProperty("didMatch").returns(true);
125
+ var matcherHandler = function(seleniumApi, command) {return mockMatcherHandlerResult;};
126
+ var assertUsingMatcherHandler = new AssertUsingMatcherHandler(matcherHandler, true);
127
+ assertUsingMatcherHandler.executeAssertion("mockSeleniumApi", "command");
128
+ mockMatcherHandlerResult.verify();
129
+ };
130
+
131
+ function testAssertUsingMatcherHandlerWithNegativeResultThrowsException() {
132
+ var mockMatcherHandlerResult = new Mock();
133
+ mockMatcherHandlerResult.expectsProperty("didMatch").returns(false);
134
+ mockMatcherHandlerResult.expectsProperty("message").returns("some message");
135
+ var matcherHandler = function(seleniumApi, command) {return mockMatcherHandlerResult;};
136
+ var assertUsingMatcherHandler = new AssertUsingMatcherHandler(matcherHandler, true);
137
+ try {
138
+ assertUsingMatcherHandler.executeAssertion("mockSeleniumApi", "command");
139
+ } catch (e) {
140
+ if (!e.isAssertionFailedError) {
141
+ throw e;
142
+ }
143
+ assertEquals("some message", e.failureMessage);
144
+ mockMatcherHandlerResult.verify();
145
+ return;
146
+ }
147
+ fail("Should have thrown an exception");
148
+ };
149
+
150
+
151
+
152
+ function testAllMethodsWithGetPrefixAreRegisteredAsAccessorsByRegisterAll() {
153
+ var actionSet = {getOne: "get1", getTwo: "get2", getdontGet: "another"};
154
+ var factory = new CommandHandlerFactory();
155
+ factory.registerAll(actionSet);
156
+
157
+ assertNull(factory.getCommandHandler("getdontGet"));
158
+ assertNull(factory.getCommandHandler("notEvenClose"));
159
+
160
+ assertEquals("get1", factory.getCommandHandler("getOne").executor);
161
+ assertEquals("get2", factory.getCommandHandler("getTwo").executor);
162
+ }
163
+
164
+ function testAllMethodsWithGetPrefixAreRegisteredAsAssertsByRegisterAll() {
165
+ var actionSet = {getOne: function(target) {return target + "foo";}, getTwo: "get2", getdontGet: "another"};
166
+ var factory = new CommandHandlerFactory();
167
+ factory.registerAll(actionSet);
168
+
169
+ assertNull(factory.getCommandHandler("assertdontGet"));
170
+ assertNull(factory.getCommandHandler("notEvenClose"));
171
+
172
+ var myAssert = factory.getCommandHandler("assertOne");
173
+ assertEquals(CommandHandler, myAssert.constructor);
174
+ assertNotNull(myAssert.executor);
175
+ assertEquals("assert", myAssert.type);
176
+ assertTrue(myAssert.haltOnFailure);
177
+ }
178
+
179
+ function testAllMethodsWithGetPrefixAreRegisteredAsVerifiesByRegisterAll() {
180
+ var actionSet = {getOne: function(target) {return target + "foo";}, getTwo: "get2", getdontGet: "another"};
181
+ var factory = new CommandHandlerFactory();
182
+ factory.registerAll(actionSet);
183
+
184
+ var myAssert = factory.getCommandHandler("verifyOne");
185
+ assertEquals(CommandHandler, myAssert.constructor);
186
+ assertNotNull(myAssert.executor);
187
+ assertEquals("assert", myAssert.type);
188
+ assertFalse(myAssert.haltOnFailure);
189
+ }
190
+
191
+ function testAllMethodsWithGetPrefixAreRegisteredAsAssertNotsByRegisterAll() {
192
+ var actionSet = {getOne: function(target) {return target + "foo";}, getTwo: "get2", getdontGet: "another"};
193
+ var factory = new CommandHandlerFactory();
194
+ factory.registerAll(actionSet);
195
+
196
+ var myAssert = factory.getCommandHandler("assertNotOne");
197
+ assertEquals(CommandHandler, myAssert.constructor);
198
+ assertNotNull(myAssert.executor);
199
+ assertEquals("assert", myAssert.type);
200
+ assertTrue(myAssert.haltOnFailure);
201
+ try {
202
+ myAssert.executor("blah", "blahfoo");
203
+ fail("Should have thrown an exception");
204
+ }
205
+ catch (e) {
206
+ // Expected.
207
+ }
208
+ }
209
+
210
+ function testAllMethodsWithGetPrefixAreRegisteredAsVerifyNotsByRegisterAll() {
211
+ var actionSet = {getOne: function(target) {return target + "foo";}, getTwo: "get2", getdontGet: "another"};
212
+ var factory = new CommandHandlerFactory();
213
+ factory.registerAll(actionSet);
214
+
215
+ var myAssert = factory.getCommandHandler("verifyNotOne");
216
+ assertEquals(CommandHandler, myAssert.constructor);
217
+ assertNotNull(myAssert.executor);
218
+ assertEquals("assert", myAssert.type);
219
+ assertFalse(myAssert.haltOnFailure);
220
+ try {
221
+ myAssert.executor("blah", "blahfoo");
222
+ fail("Should have thrown an exception");
223
+ }
224
+ catch (e) {
225
+ // Expected.
226
+ }
227
+ }
228
+
229
+
230
+ function testHaltOnFailureDefaultsToFalseForAsserts() {
231
+ var factory = new CommandHandlerFactory();
232
+ factory.registerAssert("doHalt", "assertFunction", true);
233
+ factory.registerAssert("dontHalt", "assertFunction");
234
+
235
+ assertTrue(factory.getCommandHandler("doHalt").haltOnFailure);
236
+ assertFalse(factory.getCommandHandler("dontHalt").haltOnFailure);
237
+ }
238
+
239
+ function testAllMethodsWithDoPrefixAreRegisteredAsActionsByRegisterAll() {
240
+ var actionSet = {doAnAction: "action1", doAnotherAction: "action2", dontRegister: "another"};
241
+ var factory = new CommandHandlerFactory();
242
+ factory.registerAll(actionSet);
243
+
244
+ assertNull(factory.getCommandHandler("dontRegister"));
245
+ assertNull(factory.getCommandHandler("notEvenClose"));
246
+
247
+ assertEquals("action1", factory.getCommandHandler("anAction").executor);
248
+ assertEquals("action2", factory.getCommandHandler("anotherAction").executor);
249
+ }
250
+
251
+ function testActionsAreRegisteredWithAndWaitSuffix() {
252
+ var actionSet = {doAnAction: "action1"};
253
+ var factory = new CommandHandlerFactory();
254
+ factory.registerAll(actionSet);
255
+
256
+ assertEquals("action1", factory.getCommandHandler("anAction").executor);
257
+ assertEquals("action1", factory.getCommandHandler("anActionAndWait").executor);
258
+ assertUndefined(factory.getCommandHandler("anAction").wait);
259
+ assertTrue(factory.getCommandHandler("anActionAndWait").wait);
260
+ }
261
+
262
+ function testAllMethodsWithAssertPrefixAreRegisteredForAssertAndVerifyByRegisterAll() {
263
+ var actionSet = {assertSomething: "assert1", assertSomeOtherThing: "assert2", assertionOther: "shouldn't register"};
264
+ var factory = new CommandHandlerFactory();
265
+ factory.registerAll(actionSet);
266
+
267
+ assertNull(factory.getCommandHandler("assertionOther"));
268
+ assertNull(factory.getCommandHandler("notEvenClose"));
269
+
270
+ var myAssert = factory.getCommandHandler("assertSomething");
271
+ assertEquals("assert1", myAssert.executor);
272
+ assertTrue(myAssert.haltOnFailure);
273
+ assertEquals("assert", myAssert.type);
274
+
275
+ var myVerify = factory.getCommandHandler("verifySomething");
276
+ assertEquals("assert1", myVerify.executor);
277
+ assertFalse(myVerify.haltOnFailure);
278
+ assertEquals("assert", myVerify.type);
279
+
280
+ assertEquals("assert2", factory.getCommandHandler("assertSomeOtherThing").executor);
281
+ assertEquals("assert2", factory.getCommandHandler("verifySomeOtherThing").executor);
282
+ }
283
+ </script>
284
+ </head>
285
+
286
+ <body>
287
+ <a href="#" onclick="testAllMethodsWithDoPrefixAreRegisteredAsActionsByRegisterAll();">try</a>
288
+ <p>This page contains tests for the CommandFactory object in selenium-commandhandlers.js. To see them, take a look at the source. To run them, load this file via JsUnit's testRunner.html</p>
289
+ </body>
290
+ </html>