rubinium 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,53 @@
|
|
|
1
|
+
class Rubinium::TestSuite
|
|
2
|
+
attr_accessor :tests, :name, :filename, :basedir
|
|
3
|
+
|
|
4
|
+
def initialize(name = "Unnamed test suite")
|
|
5
|
+
@name = name
|
|
6
|
+
@basedir = ARGV[0] || "."
|
|
7
|
+
@tests = []
|
|
8
|
+
yield self if block_given?
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def <<(test)
|
|
12
|
+
@tests << test
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def generate
|
|
16
|
+
testfiles = []
|
|
17
|
+
@tests.each do |test|
|
|
18
|
+
filename = File.join(@basedir, test.filename)
|
|
19
|
+
testfiles << [test.name, test.filename]
|
|
20
|
+
File.open(filename, "w") do |file|
|
|
21
|
+
test.generate(file)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
generate_suite testfiles
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def clear
|
|
28
|
+
@tests.clear
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
def generate_suite(testfiles)
|
|
33
|
+
return if testfiles.empty?
|
|
34
|
+
tests = testfiles.map do |elem|
|
|
35
|
+
name, file = elem
|
|
36
|
+
"#{' ' * 6}<tr><td><a href='#{file}'>#{name}</a></td></tr>"
|
|
37
|
+
end.join("\n")
|
|
38
|
+
suite_html = <<EOF
|
|
39
|
+
<html><head><title>#{@name}</title></head>
|
|
40
|
+
<body>
|
|
41
|
+
<table>
|
|
42
|
+
<tr><td>#{@name}</td></tr>
|
|
43
|
+
#{tests}
|
|
44
|
+
</table>
|
|
45
|
+
</body>
|
|
46
|
+
</html>
|
|
47
|
+
EOF
|
|
48
|
+
suite_filename = @filename || "#{@name.gsub(/ /, "_")}.html"
|
|
49
|
+
File.open(File.join(@basedir, suite_filename), "w") { |f|
|
|
50
|
+
f.write(suite_html)
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require_gem 'rubinium'
|
|
3
|
+
|
|
4
|
+
class TestClick < Rubinium::TestBase
|
|
5
|
+
open './tests/html/test_click_page1.html'
|
|
6
|
+
verifyText 'link', 'Click here for next page'
|
|
7
|
+
clickAndWait 'link'
|
|
8
|
+
verifyTitle 'Click Page Target'
|
|
9
|
+
clickAndWait 'previousPage'
|
|
10
|
+
verifyTitle 'Click Page 1'
|
|
11
|
+
clickAndWait 'linkWithEnclosedImage'
|
|
12
|
+
verifyTitle 'Click Page Target'
|
|
13
|
+
clickAndWait 'previousPage'
|
|
14
|
+
clickAndWait 'enclosedImage'
|
|
15
|
+
verifyTitle 'Click Page Target'
|
|
16
|
+
clickAndWait 'previousPage'
|
|
17
|
+
click 'linkToAnchorOnThisPage'
|
|
18
|
+
verifyTitle 'Click Page 1'
|
|
19
|
+
click 'linkWithOnclickReturnsFalse'
|
|
20
|
+
pause 300
|
|
21
|
+
verifyTitle 'Click Page 1'
|
|
22
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require_gem 'rubinium'
|
|
3
|
+
|
|
4
|
+
class TestOpen < Rubinium::TestBase
|
|
5
|
+
open './tests/html/test_open.html'
|
|
6
|
+
verifyLocation '/tests/html/test_open.html'
|
|
7
|
+
verifyTextPresent 'This is a test of the open command.'
|
|
8
|
+
open './tests/html/test_slowloading_page.html'
|
|
9
|
+
verifyLocation '/tests/html/test_slowloading_page.html'
|
|
10
|
+
verifyTitle 'Slow Loading Page'
|
|
11
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'rubinium.rb'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
require '../lib/rubinium.rb'
|
|
5
|
+
end
|
|
6
|
+
require 'test/unit'
|
|
7
|
+
require 'tmpdir'
|
|
8
|
+
require 'fileutils'
|
|
9
|
+
require 'rexml/document'
|
|
10
|
+
|
|
11
|
+
class FooTest < Rubinium::TestBase
|
|
12
|
+
open 'index.html'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class BarTest < Rubinium::TestBase
|
|
16
|
+
open 'index.html'
|
|
17
|
+
verifyTitle 'Some title'
|
|
18
|
+
verifyValue 'nameField', 'J. Random Hacker'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class SuiteTest < Test::Unit::TestCase
|
|
22
|
+
|
|
23
|
+
def setup
|
|
24
|
+
@basedir = Dir.tmpdir
|
|
25
|
+
@suite_filename = 'test_suite.html'
|
|
26
|
+
@suite_html = File.join(@basedir, @suite_filename)
|
|
27
|
+
@test_html = File.join(@basedir, FooTest.filename)
|
|
28
|
+
|
|
29
|
+
@suite = Rubinium::TestSuite.new do |suite|
|
|
30
|
+
suite.filename = @suite_filename
|
|
31
|
+
suite.basedir = @basedir
|
|
32
|
+
suite.name = "Sample Test"
|
|
33
|
+
suite << FooTest
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def teardown
|
|
38
|
+
[@suite_html, @test_html].each { |f| FileUtils.rm(f) if File.exists?(f) }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_should_create_an_html_suite_and_an_html_test_case
|
|
42
|
+
@suite.generate
|
|
43
|
+
assert(File.exists?(@suite_html))
|
|
44
|
+
assert(File.exists?(@test_html))
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_should_not_create_files_for_an_empty_suite
|
|
48
|
+
@suite.clear
|
|
49
|
+
@suite.generate
|
|
50
|
+
assert( !File.exists?(@suite_html))
|
|
51
|
+
assert( !File.exists?(@test_html))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_should_generate_well_formed_html
|
|
55
|
+
@suite.generate
|
|
56
|
+
suite_html = REXML::Document.new(File.open(@suite_html))
|
|
57
|
+
test_html = REXML::Document.new(File.open(@test_html))
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
data/test/ts_rubinium.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'tc_file_creation.rb'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Copy the "selenium" folder to a web accessible directory in the same web server as the application you want to test.
|
|
2
|
+
In Apache, this would mean a subdirectory of "htdocs".
|
|
3
|
+
|
|
4
|
+
Because of javascript security settings standard in most browsers, Selenium needs to be available on the same host and port as your application.
|
|
5
|
+
|
|
6
|
+
Once deployed to the server, to run Selenium's self-tests, check out:
|
|
7
|
+
http://<webservername>:<port>/selenium/TestRunner.html
|
|
8
|
+
|
|
9
|
+
Read the website for more details. (http://selenium.thoughtworks.com)
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright 2004 ThoughtWorks, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
-->
|
|
16
|
+
<html>
|
|
17
|
+
<head>
|
|
18
|
+
<meta content="text/html; charset=ISO-8859-1"
|
|
19
|
+
http-equiv="content-type">
|
|
20
|
+
<title>Selenium Functional Test Runner</title>
|
|
21
|
+
<link rel="stylesheet" type="text/css" href="selenium.css" />
|
|
22
|
+
<script language="JavaScript" type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
|
|
23
|
+
<script type="text/javascript" src="xmlextras.js"></script>
|
|
24
|
+
|
|
25
|
+
<script language="JavaScript" type="text/javascript" src="selenium-browserbot.js"></script>
|
|
26
|
+
<script language="JavaScript" type="text/javascript" src="selenium-api.js"></script>
|
|
27
|
+
<script language="JavaScript" type="text/javascript" src="selenium-commandhandlers.js"></script>
|
|
28
|
+
<script language="JavaScript" type="text/javascript" src="selenium-executionloop.js"></script>
|
|
29
|
+
<script language="JavaScript" type="text/javascript" src="selenium-tableparser.js"></script>
|
|
30
|
+
<script language="JavaScript" type="text/javascript" src="selenium-logging.js"></script>
|
|
31
|
+
<script language="JavaScript" type="text/javascript" src="htmlutils.js"></script>
|
|
32
|
+
<script language="JavaScript" type="text/javascript" src="xpath.js"></script>
|
|
33
|
+
<script language="JavaScript" type="text/javascript" src="user-extensions.js"></script>
|
|
34
|
+
<script language="JavaScript" type="text/javascript">
|
|
35
|
+
function openDomViewer() {
|
|
36
|
+
var autFrame = document.getElementById('myiframe');
|
|
37
|
+
var autFrameDocument = getIframeDocument(autFrame);
|
|
38
|
+
var domViewer = window.open('domviewer.html');
|
|
39
|
+
domViewer.rootDocument = autFrameDocument;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
<script>
|
|
44
|
+
passColor = "#cfffcf";
|
|
45
|
+
failColor = "#ffcfcf";
|
|
46
|
+
errorColor = "#ffffff";
|
|
47
|
+
workingColor = "#DEE7EC";
|
|
48
|
+
doneColor = "#FFFFCC";
|
|
49
|
+
|
|
50
|
+
slowMode = false;
|
|
51
|
+
|
|
52
|
+
var cmd1 = document.createElement("div");
|
|
53
|
+
var cmd2 = document.createElement("div");
|
|
54
|
+
var cmd3 = document.createElement("div");
|
|
55
|
+
var cmd4 = document.createElement("div");
|
|
56
|
+
|
|
57
|
+
var postResult = "OK";
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
function runTest() {
|
|
61
|
+
tableParser = new TableParser();
|
|
62
|
+
var testAppFrame = document.getElementById('myiframe');
|
|
63
|
+
selenium = Selenium.createForFrame(testAppFrame);
|
|
64
|
+
|
|
65
|
+
commandFactory = new CommandHandlerFactory();
|
|
66
|
+
commandFactory.registerAll(selenium);
|
|
67
|
+
|
|
68
|
+
testLoop = new TestLoop(commandFactory);
|
|
69
|
+
|
|
70
|
+
testLoop.firstCommand = startup;
|
|
71
|
+
testLoop.nextCommand = nextCommand;
|
|
72
|
+
testLoop.commandStarted = commandStarted;
|
|
73
|
+
testLoop.commandComplete = commandComplete;
|
|
74
|
+
testLoop.commandError = commandError;
|
|
75
|
+
testLoop.testComplete = function() {window.status = "Selenium Tests Complete, for this Test"};
|
|
76
|
+
|
|
77
|
+
testLoop.start();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function startup() {
|
|
81
|
+
|
|
82
|
+
var xmlHttp = XmlHttp.create();
|
|
83
|
+
|
|
84
|
+
document.getElementById("commandList").appendChild(cmd4);
|
|
85
|
+
document.getElementById("commandList").appendChild(cmd3);
|
|
86
|
+
document.getElementById("commandList").appendChild(cmd2);
|
|
87
|
+
document.getElementById("commandList").appendChild(cmd1);
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
xmlHttp.open("GET", "driver?seleniumStart=true", false);
|
|
91
|
+
xmlHttp.send(null);
|
|
92
|
+
} catch(e) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return extractCommand(xmlHttp);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function nextCommand() {
|
|
99
|
+
|
|
100
|
+
var xmlHttp = XmlHttp.create();
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
xmlHttp.open("GET", "driver?commandResult=" + postResult, false);
|
|
104
|
+
xmlHttp.send(null);
|
|
105
|
+
} catch(e) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return extractCommand(xmlHttp);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function extractCommand(xmlHttp) {
|
|
112
|
+
|
|
113
|
+
if (slowMode) {
|
|
114
|
+
delay(2000);
|
|
115
|
+
}
|
|
116
|
+
var command;
|
|
117
|
+
try {
|
|
118
|
+
command = xmlHttp.responseText;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
alert('could not get responseText: ' + e.message);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if (command.substr(0,'|testComplete'.length)=='|testComplete') {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
return tableParser.createCommandFromWikiRow(command);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function commandStarted(command) {
|
|
131
|
+
commandNode = document.createElement("div");
|
|
132
|
+
innerHTML = command.command + '(';
|
|
133
|
+
if (command.target != null && command.target != "") {
|
|
134
|
+
innerHTML += command.target;
|
|
135
|
+
if (command.value != null && command.value != "") {
|
|
136
|
+
innerHTML += ', ' + command.value;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
innerHTML += ")";
|
|
140
|
+
commandNode.innerHTML = innerHTML;
|
|
141
|
+
commandNode.style.backgroundColor = workingColor;
|
|
142
|
+
document.getElementById("commandList").removeChild(cmd1);
|
|
143
|
+
document.getElementById("commandList").removeChild(cmd2);
|
|
144
|
+
document.getElementById("commandList").removeChild(cmd3);
|
|
145
|
+
document.getElementById("commandList").removeChild(cmd4);
|
|
146
|
+
cmd4 = cmd3;
|
|
147
|
+
cmd3 = cmd2;
|
|
148
|
+
cmd2 = cmd1;
|
|
149
|
+
cmd1 = commandNode;
|
|
150
|
+
document.getElementById("commandList").appendChild(cmd4);
|
|
151
|
+
document.getElementById("commandList").appendChild(cmd3);
|
|
152
|
+
document.getElementById("commandList").appendChild(cmd2);
|
|
153
|
+
document.getElementById("commandList").appendChild(cmd1);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function commandComplete(result) {
|
|
157
|
+
if (result.failed) {
|
|
158
|
+
postResult = result.failureMessage;
|
|
159
|
+
commandNode.title = result.failureMessage;
|
|
160
|
+
commandNode.style.backgroundColor = failColor;
|
|
161
|
+
} else if (result.passed) {
|
|
162
|
+
postResult = "PASSED";
|
|
163
|
+
commandNode.style.backgroundColor = passColor;
|
|
164
|
+
} else {
|
|
165
|
+
postResult = result.result;
|
|
166
|
+
commandNode.style.backgroundColor = doneColor;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function commandError(message) {
|
|
171
|
+
postResult = "ERROR"
|
|
172
|
+
commandNode.style.backgroundColor = errorColor;
|
|
173
|
+
commandNode.title = message;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function slowClicked() {
|
|
177
|
+
slowMode = !slowMode;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
function delay(millis) {
|
|
182
|
+
startMillis = new Date();
|
|
183
|
+
while (true) {
|
|
184
|
+
milli = new Date();
|
|
185
|
+
if (milli-startMillis > millis) {
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function getIframeDocument(iframe) {
|
|
192
|
+
if (iframe.contentDocument) {
|
|
193
|
+
return iframe.contentDocument;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
return iframe.contentWindow.document;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
</script>
|
|
201
|
+
</head>
|
|
202
|
+
|
|
203
|
+
<body onLoad="runTest()">
|
|
204
|
+
|
|
205
|
+
<table border="1" style="height: 100%;">
|
|
206
|
+
<tr>
|
|
207
|
+
<td width="50%" height="30%">
|
|
208
|
+
<table>
|
|
209
|
+
<tr>
|
|
210
|
+
<td>
|
|
211
|
+
<img src="selenium-logo.png">
|
|
212
|
+
</td>
|
|
213
|
+
<td>
|
|
214
|
+
<h1><a href="http://selenium.thoughtworks.com" >Selenium</a> Functional Testing for Web Apps</h1>
|
|
215
|
+
Open Source From <a href="http://www.thoughtworks.com">ThoughtWorks, Inc</a> and Friends
|
|
216
|
+
<form action="">
|
|
217
|
+
<br/>Slow Mode:<INPUT TYPE="CHECKBOX" NAME="FASTMODE" VALUE="YES" onmouseup="slowClicked()">
|
|
218
|
+
|
|
219
|
+
<fieldset>
|
|
220
|
+
<legend>Tools</legend>
|
|
221
|
+
|
|
222
|
+
<button type="button" id="domViewer1" onclick="openDomViewer();">
|
|
223
|
+
View DOM
|
|
224
|
+
</button>
|
|
225
|
+
<button type="button" onclick="LOG.show();">
|
|
226
|
+
Show Log
|
|
227
|
+
</button>
|
|
228
|
+
</fieldset>
|
|
229
|
+
|
|
230
|
+
</form>
|
|
231
|
+
|
|
232
|
+
</td>
|
|
233
|
+
</tr>
|
|
234
|
+
</table>
|
|
235
|
+
<form action="">
|
|
236
|
+
<label id="context" name="context"></label>
|
|
237
|
+
</form>
|
|
238
|
+
</td>
|
|
239
|
+
<td width="50%" height="30%">
|
|
240
|
+
<b>Last Four Commands</b><br/>
|
|
241
|
+
<div id="commandList"></div>
|
|
242
|
+
</td>
|
|
243
|
+
</tr>
|
|
244
|
+
<tr>
|
|
245
|
+
<td colspan="2" height="70%">
|
|
246
|
+
<iframe name="myiframe" id="myiframe" src="" height="100%" width="100%"></iframe>
|
|
247
|
+
</td>
|
|
248
|
+
</tr>
|
|
249
|
+
</table>
|
|
250
|
+
|
|
251
|
+
</body>
|
|
252
|
+
</html>
|
|
253
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
|
|
3
|
+
<head>
|
|
4
|
+
<title>Selenium Log Console</title>
|
|
5
|
+
<link id="cssLink" rel="stylesheet" href="selenium.css" />
|
|
6
|
+
|
|
7
|
+
</head>
|
|
8
|
+
<body id="logging-console">
|
|
9
|
+
|
|
10
|
+
<script language="JavaScript">
|
|
11
|
+
|
|
12
|
+
var logLevels = {
|
|
13
|
+
debug: 0,
|
|
14
|
+
info: 1,
|
|
15
|
+
warn: 2,
|
|
16
|
+
error: 3
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function getThresholdLevel() {
|
|
20
|
+
var buttons = document.getElementById('logLevelChooser').level;
|
|
21
|
+
for (var i = 0; i < buttons.length; i++) {
|
|
22
|
+
if (buttons[i].checked) {
|
|
23
|
+
return buttons[i].value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function append(message, logLevel) {
|
|
29
|
+
if (logLevels[logLevel] < logLevels[getThresholdLevel()]) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
var log = document.getElementById('log');
|
|
33
|
+
var newEntry = document.createElement('li');
|
|
34
|
+
newEntry.className = logLevel;
|
|
35
|
+
newEntry.appendChild(document.createTextNode(message));
|
|
36
|
+
log.appendChild(newEntry);
|
|
37
|
+
if (newEntry.scrollIntoView) {
|
|
38
|
+
newEntry.scrollIntoView();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<div id="banner">
|
|
45
|
+
<form id="logLevelChooser">
|
|
46
|
+
<input id="level-error" type="radio" name="level"
|
|
47
|
+
value="error" /><label for="level-error">Error</label>
|
|
48
|
+
<input id="level-warn" type="radio" name="level"
|
|
49
|
+
value="warn" /><label for="level-warn">Warn</label>
|
|
50
|
+
<input id="level-info" type="radio" name="level" checked="yes"
|
|
51
|
+
value="info" /><label for="level-info">Info</label>
|
|
52
|
+
<input id="level-debug" type="radio" name="level"
|
|
53
|
+
value="debug" /><label for="level-debug">Debug</label>
|
|
54
|
+
</form>
|
|
55
|
+
<h1>Selenium Log Console</h1>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<ul id="log"></ul>
|
|
59
|
+
|
|
60
|
+
</body>
|
|
61
|
+
</html>
|