rubinium 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +7 -0
- data/MIT-LICENSE +21 -0
- data/README +137 -0
- data/Rakefile +139 -0
- data/TODO +7 -0
- data/doc/examples/rtc_site_live.rb +12 -0
- data/doc/examples/rts_main.rb +9 -0
- data/doc/examples/rts_shared_code.rb +25 -0
- data/lib/rubinium.rb +9 -0
- data/lib/rubinium/string.rb +3 -0
- data/lib/rubinium/test_base.rb +80 -0
- data/lib/rubinium/test_suite.rb +53 -0
- data/lib/rubinium/validator.rb +16 -0
- data/test/selenium_tests/test_click.rb +22 -0
- data/test/selenium_tests/test_open.rb +11 -0
- data/test/tc_file_creation.rb +60 -0
- data/test/ts_rubinium.rb +1 -0
- data/vendor/selenium-0.6.0/install-readme.txt +9 -0
- data/vendor/selenium-0.6.0/selenium/SeleneseRunner.html +253 -0
- data/vendor/selenium-0.6.0/selenium/SeleniumLog.html +61 -0
- data/vendor/selenium-0.6.0/selenium/TestRunner-splash.html +55 -0
- data/vendor/selenium-0.6.0/selenium/TestRunner.hta +146 -0
- data/vendor/selenium-0.6.0/selenium/TestRunner.html +146 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestClickInFrame.html +58 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInFrame.html +48 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInNewWindow.html +78 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestOpenMeta.html +43 -0
- data/vendor/selenium-0.6.0/selenium/devtests/TestSuite.html +39 -0
- data/vendor/selenium-0.6.0/selenium/devtests/meta/page.html +5 -0
- data/vendor/selenium-0.6.0/selenium/dom-images/butmin.gif +0 -0
- data/vendor/selenium-0.6.0/selenium/dom-images/butplus.gif +0 -0
- data/vendor/selenium-0.6.0/selenium/dom-styles/default.css +298 -0
- data/vendor/selenium-0.6.0/selenium/domviewer.html +16 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/carnation.jpg +0 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/example.html +75 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath-patched.js +657 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath.js +610 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/license.txt +504 -0
- data/vendor/selenium-0.6.0/selenium/html-xpath/rainbow.jpg +0 -0
- data/vendor/selenium-0.6.0/selenium/htmlutils.js +283 -0
- data/vendor/selenium-0.6.0/selenium/index.html +60 -0
- data/vendor/selenium-0.6.0/selenium/jsmock/mock-tests.html +205 -0
- data/vendor/selenium-0.6.0/selenium/jsmock/mock.js +124 -0
- data/vendor/selenium-0.6.0/selenium/selenium-api.js +683 -0
- data/vendor/selenium-0.6.0/selenium/selenium-browserbot.js +930 -0
- data/vendor/selenium-0.6.0/selenium/selenium-commandhandlers.js +286 -0
- data/vendor/selenium-0.6.0/selenium/selenium-domviewer.js +188 -0
- data/vendor/selenium-0.6.0/selenium/selenium-executionloop.js +250 -0
- data/vendor/selenium-0.6.0/selenium/selenium-fitrunner.js +597 -0
- data/vendor/selenium-0.6.0/selenium/selenium-logging.js +88 -0
- data/vendor/selenium-0.6.0/selenium/selenium-logo.png +0 -0
- data/vendor/selenium-0.6.0/selenium/selenium-tableparser.js +50 -0
- data/vendor/selenium-0.6.0/selenium/selenium.css +211 -0
- data/vendor/selenium-0.6.0/selenium/tests/ErrorCheckingTestSuite.html +36 -0
- data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSearch.html +69 -0
- data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSuite.html +32 -0
- data/vendor/selenium-0.6.0/selenium/tests/JsUnitSuite.html +38 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestClick.html +128 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestClickJavascriptHref.html +115 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestCommandError.html +79 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestConfirmations.html +77 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestErrorChecking.html +71 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestFailingAssert.html +59 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestFailingVerifications.html +198 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestFocusOnBlur.html +53 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestGoBack.html +81 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestImplicitLocators.html +81 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestJavascriptParameters.html +91 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestLocators.html +161 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestModalDialog.html +58 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestModalDialogDialog.html +48 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestOpen.html +66 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestPatternMatching.html +127 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestPause.html +78 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestPrompting.html +82 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestProxy.html +62 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSelect.html +111 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSelectWindow.html +106 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestStore.html +165 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSuite-InternetExplorer.html +79 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Konqueror.html +75 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Safari.html +75 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestSuite.html +75 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestType.html +79 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestUserExtensions.html +81 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifications.html +164 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlerts.html +80 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlertsFailures.html +108 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyConfirmationFailures.html +86 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditable.html +70 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditableFailures.html +95 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVisibility.html +91 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestVisibilityFailures.html +131 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestWait.html +112 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestWaitFor.html +63 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestWaitInPopupWindow.html +94 -0
- data/vendor/selenium-0.6.0/selenium/tests/TestXPathLocators.html +98 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/alert-handling-tests.html +79 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/assert-tests.html +113 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/browserbot-tests.html +123 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-factory-tests.html +290 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-handler-tests.html +115 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/confirm-handling-tests.html +97 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/error-checking-command-tests.html +198 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/event-bubble-tests.html +106 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/optionlocator-tests.html +180 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-accessor-tests.html +65 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-action-tests.html +200 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-attribute-tests.html +98 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests-include.html +33 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests.html +258 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-property-tests.html +49 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/pattern-matcher-tests.html +66 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-api-tests.html +412 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-parameter-tests.html +98 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/suite.html +52 -0
- data/vendor/selenium-0.6.0/selenium/tests/browserbot/testloop-handle-error-tests.html +74 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestButtonEvents.html +72 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestCheckboxEvents.html +107 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestFireEvents.html +75 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestLinkEvents.html +43 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestRadioEvents.html +149 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestSelectEvents.html +122 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/TestTextEvents.html +87 -0
- data/vendor/selenium-0.6.0/selenium/tests/events/readme.txt +26 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/banner.gif +0 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_async_event.html +36 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_click_javascript_page.html +34 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page1.html +31 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page2.html +30 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_confirm.html +34 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_dummy_page.html +26 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_editable.html +36 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_focus_on_blur.html +33 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_form_events.html +98 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_framed_page.html +7 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_just_text.html +22 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_locators.html +34 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog.html +29 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog_dialog.html +35 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_open.html +23 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_prompt.html +34 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_reload_onchange_page.html +32 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_select.html +35 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window.html +29 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window_popup.html +28 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_slowloading_page.html +27 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_store_value.html +23 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page1.html +37 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page2.html +61 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_verifications.html +42 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_verify_alert.html +46 -0
- data/vendor/selenium-0.6.0/selenium/tests/html/test_visibility.html +53 -0
- data/vendor/selenium-0.6.0/selenium/tests/readme.txt +1 -0
- data/vendor/selenium-0.6.0/selenium/tests/tableparser/tableparser-tests.html +122 -0
- data/vendor/selenium-0.6.0/selenium/tests/tinyWebServer.py +70 -0
- data/vendor/selenium-0.6.0/selenium/user-extensions.js.sample +62 -0
- data/vendor/selenium-0.6.0/selenium/version.txt +1 -0
- data/vendor/selenium-0.6.0/selenium/xmlextras.js +153 -0
- data/vendor/selenium-0.6.0/selenium/xpath.js +3910 -0
- 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>
|