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,180 @@
1
+
2
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
3
+ "http://www.w3.org/TR/html4/loose.dtd">
4
+
5
+ <!--
6
+ Copyright 2004 ThoughtWorks, Inc
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+ -->
20
+ <html>
21
+ <head>
22
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
23
+ <title>Option Locator tests</title>
24
+ <link rel="stylesheet" type="text/css" href="/jsunit/css/jsUnitStyle.css">
25
+ <script language="JavaScript" type="text/javascript" src="/jsunit/app/jsUnitCore.js"></script>
26
+ <script language="JavaScript" type="text/javascript" src="/jsmock/mock.js"></script>
27
+
28
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
29
+ <script language="JavaScript" type="text/javascript" src="/selenium-api.js"></script>
30
+ <script language="JavaScript" type="text/javascript">
31
+
32
+ function setUp() {
33
+ mockSelect = new Object();
34
+ mockSelect.options = [{text: "Option Zero", value: "option0"},
35
+ {text: "Option One", value: "option1"},
36
+ {text: "Option Two", value: "option2"},
37
+ {text: "", value: ""}];
38
+ mockSelect.selectedIndex = 1;
39
+ optionLocatorFactory = new OptionLocatorFactory();
40
+ }
41
+
42
+ function testSelectByIndexSuccess() {
43
+ var locator = optionLocatorFactory.fromLocatorString("index=2");
44
+ var option = locator.findOption(mockSelect);
45
+ assertEquals("option2", option.value);
46
+ }
47
+
48
+ function testSelectByIndexOutOfBounds() {
49
+ var locator = optionLocatorFactory.fromLocatorString("index=" + mockSelect.options.length);
50
+ assertCallFails("Should not be able to find an option out of bounds",
51
+ function() {locator.findOption(mockSelect);});
52
+ }
53
+
54
+ function testSelectByLabelSuccess() {
55
+ var locator = optionLocatorFactory.fromLocatorString("label=Opt*Two");
56
+ var option = locator.findOption(mockSelect);
57
+ assertEquals("option2", option.value);
58
+ }
59
+
60
+ function testSelectByLabelFailure() {
61
+ var locator = optionLocatorFactory.fromLocatorString("label=nosuchlabel");
62
+ assertCallFails(
63
+ "Should not be able to find an option with label of 'nosuchlabel'",
64
+ function() {locator.findOption(mockSelect);});
65
+ }
66
+
67
+ function testSelectByValueSuccess() {
68
+ var locator = optionLocatorFactory.fromLocatorString("value=opt*2");
69
+ var option = locator.findOption(mockSelect);
70
+ assertEquals("option2", option.value);
71
+ }
72
+
73
+ function testSelectByValueFailure() {
74
+ var locator = optionLocatorFactory.fromLocatorString("value=nosuchvalue");
75
+ assertCallFails(
76
+ "Should not be able to find an option with label of 'nosuchvalue'",
77
+ function() {locator.findOption(mockSelect);});
78
+ }
79
+
80
+ function testAssertSelectedByLabelSuccess() {
81
+ var locator = optionLocatorFactory.fromLocatorString("label=Option One");
82
+ locator.assertSelected(mockSelect);
83
+ }
84
+
85
+ function testAssertSelectedByLabelFailure() {
86
+ var locator = optionLocatorFactory.fromLocatorString("label=O*ion Two");
87
+ assertAssertionFails("assertSelect should have failed",
88
+ function() {locator.assertSelected(mockSelect);});
89
+ }
90
+
91
+ function testAssertSelectedByValueSuccess() {
92
+ var locator = optionLocatorFactory.fromLocatorString("value=opt*n1");
93
+ locator.assertSelected(mockSelect);
94
+ }
95
+
96
+ function testAssertSelectedByValueFailure() {
97
+ var locator = optionLocatorFactory.fromLocatorString("value=option2");
98
+ assertAssertionFails("assertSelect should have failed",
99
+ function() {locator.assertSelected(mockSelect);});
100
+ }
101
+
102
+ function testAssertSelectedByIndexSuccess() {
103
+ var locator = optionLocatorFactory.fromLocatorString("index=1");
104
+ locator.assertSelected(mockSelect);
105
+ }
106
+
107
+ function testAssertSelectedByIndexFailure() {
108
+ var locator = optionLocatorFactory.fromLocatorString("index=2");
109
+ assertAssertionFails("assertSelect should have failed",
110
+ function() {locator.assertSelected(mockSelect);});
111
+ }
112
+
113
+ function testAssertSelectedByEmptyLabelSuccess() {
114
+ mockSelect.selectedIndex = 3;
115
+ var locator = optionLocatorFactory.fromLocatorString("label=");
116
+ locator.assertSelected(mockSelect);
117
+ }
118
+
119
+ function testAssertSelectedByEmptyLabelFailure() {
120
+ var locator = optionLocatorFactory.fromLocatorString("label=");
121
+ assertAssertionFails("assertSelect should have failed",
122
+ function(){locator.assertSelected(mockSelect);});
123
+ }
124
+
125
+ function testAssertSelectedWithIndexOutOfBounds() {
126
+ var locator = optionLocatorFactory.fromLocatorString("index=" + mockSelect.options.length);
127
+ assertAssertionFails("assertSelect should have failed",
128
+ function() {locator.assertSelected(mockSelect);});
129
+ }
130
+
131
+ function testOptionLocatorWithBadLocatorType() {
132
+ assertCallFails(
133
+ "Should not be able to create a locator with an unkown type",
134
+ function() {optionLocatorFactory.fromLocatorString("badtype=foo");});
135
+ }
136
+
137
+ function testOptionLocatorWithBadIndex() {
138
+ assertCallFails(
139
+ "Should not be able to create a locator with a bad index.",
140
+ function() {optionLocatorFactory.fromLocatorString("index=foo");});
141
+ }
142
+
143
+ function testOptionLocatorWithNegativeIndex() {
144
+ assertCallFails(
145
+ "Should not be able to create a locator with a bad index.",
146
+ function() {optionLocatorFactory.fromLocatorString("index=-100");});
147
+ }
148
+
149
+
150
+ function assertCallFails(message, theCall, expectedFailureMessage) {
151
+ try {
152
+ theCall();
153
+ } catch (expected) {
154
+ if (expectedFailureMessage) {
155
+ assertEquals(expectedFailureMessage, e.failureMessage);
156
+ }
157
+ return;
158
+ }
159
+ fail(message);
160
+ }
161
+
162
+ function assertAssertionFails(message, theCall, expectedFailureMessage) {
163
+ try {
164
+ theCall();
165
+ } catch (e) {
166
+ if (!e.isAssertionFailedError) {
167
+ throw e;
168
+ }
169
+ if (expectedFailureMessage) {
170
+ assertEquals(expectedFailureMessage, e.failureMessage);
171
+ }
172
+ return;
173
+ }
174
+ fail(message);
175
+ }
176
+
177
+ </script>
178
+ </head>
179
+ <body>Option Locator Tests</body>
180
+ </html>
@@ -0,0 +1,65 @@
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
+
27
+ <script language="JavaScript" type="text/javascript" src="/selenium-browserbot.js"></script>
28
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
29
+ <script language="JavaScript" type="text/javascript">
30
+
31
+ function setUp() {
32
+ pageBot = PageBot.createForWindow(window);
33
+ }
34
+
35
+ function testGetButtonsReturnsBothButtons() {
36
+ var result = pageBot.getAllButtons();
37
+ assertEquals("theButton,theSubmit,", result);
38
+ }
39
+
40
+ function testGetLinksReturnsLinks() {
41
+ var result = pageBot.getAllLinks();
42
+ assertEquals("myLink,myOtherLink,yetAnotherLink,", result);
43
+ }
44
+
45
+ function testGetFieldsReturnsFields() {
46
+ var result = pageBot.getAllFields();
47
+ assertEquals("theTextbox,theOtherTextbox,", result);
48
+ }
49
+ </script>
50
+ </head>
51
+
52
+ <body>
53
+ <h1>Selenium Browserbot Tests</h1>
54
+
55
+ <form id="theForm" name="theForm" onsubmit="return false;">
56
+ <a id="myLink" href="test_click_page2.html">This is a link</a>
57
+ <a id="myOtherLink" href="test_click_page2.html">So is this</a>
58
+ <a id="yetAnotherLink" href="test_click_page2.html">This too</a>
59
+ <input name="theTextbox" id="theTextbox" type="text" value="theTextbox"/>
60
+ <input name="theOtherTextbox" id="theOtherTextbox" type="text" value="theOtherTextbox"/>
61
+ <input name="theButton" id="theButton" type="button" value="The Button"/>
62
+ <input name="theSubmit" id="theSubmit" type="submit" value="The Submit"/>
63
+ </form>
64
+ </body>
65
+ </html>
@@ -0,0 +1,200 @@
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
+
27
+ <script language="JavaScript" type="text/javascript" src="/selenium-browserbot.js"></script>
28
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
29
+ <script language="JavaScript" type="text/javascript">
30
+
31
+ function setUp() {
32
+ initialiseSelect()
33
+ initialiseTextbox()
34
+ initialiseCheckbox()
35
+ initialiseRadios()
36
+ initialiseButtons()
37
+ pageBot = PageBot.createForWindow(window);
38
+ }
39
+
40
+ function attachEventListeners(element, eventSink) {
41
+ element.onfocus = function() {eventSink.push('focus')}
42
+ element.onselect = function() {eventSink.push('select')}
43
+ element.onclick = function() {eventSink.push('click')}
44
+ element.onchange = function() {eventSink.push('change')}
45
+ element.onblur = function() {eventSink.push('blur')}
46
+ }
47
+
48
+ function initialiseSelect() {
49
+ theSelect = document.getElementById("theSelect")
50
+ theSelect.options[1].selected = true
51
+
52
+ theSelectEvents = new Array()
53
+ attachEventListeners(theSelect, theSelectEvents)
54
+
55
+ assertEquals("option2", theSelect.value)
56
+ }
57
+
58
+ function initialiseTextbox() {
59
+ theTextbox = document.getElementById("theTextbox")
60
+ theTextbox.value = "theTextbox"
61
+
62
+ textboxEvents = new Array()
63
+ attachEventListeners(theTextbox, textboxEvents)
64
+ }
65
+
66
+ function initialiseCheckbox() {
67
+ theCheckbox = document.getElementById("theCheckbox")
68
+ theCheckbox.checked = false
69
+ assertFalse(theCheckbox.checked)
70
+
71
+ checkboxEvents = new Array()
72
+ attachEventListeners(theCheckbox, checkboxEvents)
73
+ }
74
+
75
+ function initialiseRadios() {
76
+ theRadio1 = document.getElementById("theRadio1")
77
+ theRadio1.checked = true
78
+ assertTrue(theRadio1.checked)
79
+ radio1Events = new Array()
80
+ attachEventListeners(theRadio1, radio1Events)
81
+
82
+ theRadio2 = document.getElementById("theRadio2")
83
+ theRadio2.checked = false
84
+ assertFalse(theRadio2.checked)
85
+ radio2Events = new Array()
86
+ attachEventListeners(theRadio2, radio2Events)
87
+ }
88
+
89
+ function initialiseButtons() {
90
+ theButton = document.getElementById("theButton")
91
+ buttonEvents = new Array()
92
+ attachEventListeners(theButton, buttonEvents)
93
+
94
+ theSubmit = document.getElementById("theSubmit")
95
+ submitEvents = new Array()
96
+ attachEventListeners(theSubmit, submitEvents)
97
+ }
98
+
99
+ function testSelectOptionShouldSelectAndTriggerFocusChangeAndBlur() {
100
+ pageBot.selectOption(theSelect, theSelect.options[2])
101
+
102
+ assertEquals("option3", theSelect.value)
103
+ assertEquals("focus,change,blur", theSelectEvents.join());
104
+ }
105
+
106
+ function testSelectAlreadySelectedOptionWithLabelShouldNotTriggerChange() {
107
+ pageBot.selectOption(theSelect, theSelect.options[1])
108
+
109
+ assertEquals("option2", theSelect.value)
110
+ assertEquals("focus,blur", theSelectEvents.join())
111
+ }
112
+
113
+ function testReplaceTextInTextBoxShouldTriggerFocusSelectChangeBlur() {
114
+ pageBot.replaceText(theTextbox, "new text")
115
+ assertEquals("new text", theTextbox.value)
116
+
117
+ assertEquals("focus,select,change,blur", textboxEvents.join())
118
+ }
119
+
120
+ function TODO_testReplaceTextShouldNotTriggerSelectIfOriginallyEmpty() {
121
+ theTextbox.value = ""
122
+
123
+ pageBot.replaceText(theTextbox, "new text")
124
+
125
+ assertEquals("new text", theTextbox.value)
126
+ assertEquals("focus,change,blur", textboxEvents.join());
127
+ }
128
+
129
+ function testClickCheckboxShouldTriggerFocusClickChangeAndBlur() {
130
+ pageBot.clickElement(theCheckbox)
131
+
132
+ assertTrue("Checkbox should be checked", theCheckbox.checked)
133
+ assertEquals("focus,click,change,blur", checkboxEvents.join())
134
+ }
135
+
136
+ function testClickCheckboxShouldUncheckIfAlreadyChecked() {
137
+ theCheckbox.checked = true
138
+ pageBot.clickElement(theCheckbox)
139
+ assertFalse("Checkbox shouldn't be checked", theCheckbox.checked)
140
+ }
141
+
142
+ function testClickRadioShouldTriggerFocusClickChangeAndBlur() {
143
+ pageBot.clickElement(theRadio2)
144
+ assertFalse("Radio1 shouldn't be checked", theRadio1.checked)
145
+ assertTrue("Radio should be checked", theRadio2.checked)
146
+
147
+ assertEquals("", radio1Events.join());
148
+ assertEquals("focus,click,change,blur", radio2Events.join())
149
+ }
150
+
151
+ function testClickRadioShouldNotTriggerChangeIfAlreadySelected() {
152
+ assertTrue(theRadio1.checked)
153
+ pageBot.clickElement(theRadio1)
154
+ assertTrue("Radio1 should be checked", theRadio1.checked)
155
+
156
+ assertEquals("focus,click,blur", radio1Events.join())
157
+ assertEquals("", radio2Events.join())
158
+ }
159
+
160
+ function testClickButtonShouldTriggerFocusClickAndBlur() {
161
+ pageBot.clickElement(theButton)
162
+
163
+ assertEquals("focus,click,blur", buttonEvents.join())
164
+ }
165
+
166
+ function testClickSubmitShouldTriggerFocusClickAndBlur() {
167
+ pageBot.clickElement(theSubmit)
168
+
169
+ assertEquals("focus,click,blur", submitEvents.join())
170
+ }
171
+
172
+ function testClickShouldNotTriggerEventsPassedClickIfWindowIsClosed() {
173
+ theButton.onclick = function() {
174
+ buttonEvents.push('clickNclose');
175
+ pageBot.windowClosed = function() {return true};
176
+ }
177
+
178
+ pageBot.clickElement(theButton);
179
+ assertEquals("focus,clickNclose", buttonEvents.join());
180
+ }
181
+ </script>
182
+ </head>
183
+
184
+ <body>
185
+ <h1>Selenium Browserbot Tests</h1>
186
+
187
+ <form id="theForm" name="theForm" onsubmit="return false;">
188
+ <input name="theTextbox" id="theTextbox" type="text" value="theTextbox"/>
189
+ <input name="theCheckbox" id="theCheckbox" type="checkbox"/>
190
+ <input name="theRadio" id="theRadio1" type="radio" value="radio1"/><input name="theRadio" id="theRadio2" type="radio" value="radio2"/>
191
+ <select name="theSelect" id="theSelect">
192
+ <option value="option1">First Option</option>
193
+ <option value="option2" selected="true">Second Option</option>
194
+ <option value="option3">Third Option</option>
195
+ </select>
196
+ <input name="theButton" id="theButton" type="button" value="The Button"/>
197
+ <input name="theSubmit" id="theSubmit" type="submit" value="The Submit"/>
198
+ </form>
199
+ </body>
200
+ </html>
@@ -0,0 +1,98 @@
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="/html-xpath/html-xpath-patched.js"></script>
27
+
28
+ <script language="JavaScript" type="text/javascript" src="/selenium-browserbot.js"></script>
29
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
30
+ <script language="JavaScript" type="text/javascript">
31
+
32
+ function setUp() {
33
+ pageBot = PageBot.createForWindow(window);
34
+ element1 = document.getElementById("id1");
35
+ element2 = document.getElementById("id2");
36
+ element3 = document.getElementById("id3");
37
+ element4 = document.getElementById("document.links[0]");
38
+ }
39
+
40
+ //
41
+ // Tests for finding attribute with id.
42
+ //
43
+ function testFindAttributeThrowsErrorIfNotElementFound() {
44
+ var errorMessage = null;
45
+ try {
46
+ pageBot.findAttribute('noSuchElement@attribute');
47
+ } catch (e) {
48
+ errorMessage = e.message;
49
+ }
50
+ assertEquals("Element noSuchElement not found", errorMessage);
51
+ }
52
+
53
+ function testFindAttributeReturnsNullIfElementDoesNotHaveAttribute() {
54
+ assertNull(pageBot.findAttribute('id1@wrong-attribute'));
55
+ }
56
+
57
+ // Different type of attributes
58
+ function testFindAttributeReturnsClassAttributeFromElementWithId() {
59
+ assertEquals("id3class", pageBot.findAttribute('id3@class'));
60
+ }
61
+
62
+ function testFindAttributeReturnsAltAttributeFromElementWithId() {
63
+ assertEquals("the second link", pageBot.findAttribute('id2@alt'));
64
+ }
65
+
66
+ function testFindAttributeReturnsCustomAttributeFromElementWithId() {
67
+ assertEquals("bar", pageBot.findAttribute("id3@foo"));
68
+ }
69
+
70
+ function testFindAttributeReturnsNumericAttributeFromElementWithId() {
71
+ assertEquals("24", pageBot.findAttribute("theInput@maxlength"));
72
+ }
73
+
74
+ // Different ways of locating elements
75
+ function testFindAttributeReturnsAttributeFromElementWithDomTraversal() {
76
+ assertEquals("bar", pageBot.findAttribute('document.links[2]@foo'));
77
+ }
78
+
79
+ function testFindAttributeReturnsAttributeFromElementWithXPath() {
80
+ assertEquals("parabar", pageBot.findAttribute('//p/@foo'));
81
+ }
82
+
83
+ function testFindAttributeReturnsAttributeFromElementWithXPathAndAttributeSelector() {
84
+ assertEquals("parabar", pageBot.findAttribute("//p[@name='name1']/@foo"));
85
+ }
86
+
87
+
88
+ </script>
89
+ </head>
90
+
91
+ <body>
92
+ <a id="id1" href="#id1">this is the first element</a>
93
+ <a id="id2" name="name1" href="#id2" alt="the second link">this is the second element</a>
94
+ <a id="id3" name="name1" href="#id3" class="id3class" foo="bar">this is the third element</a>
95
+ <p id="document.links[0]" name="name1" foo="parabar">dummy element</p>
96
+ <input name="theInput" maxlength="24"/>
97
+ </body>
98
+ </html>