caius-celerity 0.0.6.10 → 0.0.6.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +335 -0
- data/benchmark/bm_2000_spans.rb +48 -0
- data/benchmark/bm_digg.rb +26 -0
- data/benchmark/bm_google_images.rb +36 -0
- data/benchmark/bm_input_locator.rb +69 -0
- data/benchmark/bm_text_input.rb +19 -0
- data/benchmark/loader.rb +14 -0
- data/celerity.gemspec +33 -0
- data/config/hoe.rb +78 -0
- data/config/requirements.rb +9 -0
- data/lib/celerity/version.rb +1 -1
- data/spec/area_spec.rb +97 -0
- data/spec/areas_spec.rb +40 -0
- data/spec/browser_authentication_spec.rb +20 -0
- data/spec/browser_spec.rb +537 -0
- data/spec/button_spec.rb +244 -0
- data/spec/buttons_spec.rb +51 -0
- data/spec/checkbox_spec.rb +302 -0
- data/spec/checkboxes_spec.rb +38 -0
- data/spec/clickable_element_spec.rb +43 -0
- data/spec/dd_spec.rb +143 -0
- data/spec/dds_spec.rb +39 -0
- data/spec/default_viewer_spec.rb +24 -0
- data/spec/div_spec.rb +235 -0
- data/spec/divs_spec.rb +39 -0
- data/spec/dl_spec.rb +143 -0
- data/spec/dls_spec.rb +39 -0
- data/spec/dt_spec.rb +143 -0
- data/spec/dts_spec.rb +39 -0
- data/spec/element_spec.rb +150 -0
- data/spec/em_spec.rb +116 -0
- data/spec/ems_spec.rb +39 -0
- data/spec/filefield_spec.rb +133 -0
- data/spec/filefields_spec.rb +40 -0
- data/spec/form_spec.rb +59 -0
- data/spec/forms_spec.rb +41 -0
- data/spec/frame_spec.rb +139 -0
- data/spec/frames_spec.rb +71 -0
- data/spec/hidden_spec.rb +127 -0
- data/spec/hiddens_spec.rb +39 -0
- data/spec/hn_spec.rb +104 -0
- data/spec/hns_spec.rb +45 -0
- data/spec/html/2000_spans.html +2009 -0
- data/spec/html/bug_duplicate_attributes.html +14 -0
- data/spec/html/bug_javascript_001.html +11 -0
- data/spec/html/definition_lists.html +48 -0
- data/spec/html/euc-jp_text.html +17 -0
- data/spec/html/forms_with_input_elements.html +124 -0
- data/spec/html/frame_1.html +18 -0
- data/spec/html/frame_2.html +16 -0
- data/spec/html/frames.html +11 -0
- data/spec/html/iframes.html +12 -0
- data/spec/html/images.html +27 -0
- data/spec/html/images/1.gif +0 -0
- data/spec/html/images/2.gif +0 -0
- data/spec/html/images/3.gif +0 -0
- data/spec/html/images/button.jpg +0 -0
- data/spec/html/images/circle.jpg +0 -0
- data/spec/html/images/map.gif +0 -0
- data/spec/html/images/map2.gif +0 -0
- data/spec/html/images/minus.gif +0 -0
- data/spec/html/images/originaltriangle.jpg +0 -0
- data/spec/html/images/plus.gif +0 -0
- data/spec/html/images/square.jpg +0 -0
- data/spec/html/images/triangle.jpg +0 -0
- data/spec/html/iso-2022-jp_text.html +17 -0
- data/spec/html/jquery.html +29 -0
- data/spec/html/latin1_text.html +17 -0
- data/spec/html/multiple_ids.html +14 -0
- data/spec/html/non_control_elements.html +115 -0
- data/spec/html/right_click.html +16 -0
- data/spec/html/shift_jis_text.html +17 -0
- data/spec/html/tables.html +119 -0
- data/spec/html/timeout.html +16 -0
- data/spec/html/tiny_mce.html +29 -0
- data/spec/html/utf8_text.html +15 -0
- data/spec/htmlunit_spec.rb +47 -0
- data/spec/image_spec.rb +221 -0
- data/spec/images_spec.rb +39 -0
- data/spec/index_offset_spec.rb +26 -0
- data/spec/label_spec.rb +88 -0
- data/spec/labels_spec.rb +40 -0
- data/spec/li_spec.rb +139 -0
- data/spec/link_spec.rb +200 -0
- data/spec/links_spec.rb +47 -0
- data/spec/lis_spec.rb +40 -0
- data/spec/listener_spec.rb +142 -0
- data/spec/map_spec.rb +102 -0
- data/spec/maps_spec.rb +40 -0
- data/spec/meta_spec.rb +29 -0
- data/spec/metas_spec.rb +38 -0
- data/spec/ol_spec.rb +87 -0
- data/spec/ols_spec.rb +40 -0
- data/spec/option_spec.rb +156 -0
- data/spec/p_spec.rb +171 -0
- data/spec/pre_spec.rb +135 -0
- data/spec/pres_spec.rb +40 -0
- data/spec/ps_spec.rb +40 -0
- data/spec/radio_spec.rb +314 -0
- data/spec/radios_spec.rb +42 -0
- data/spec/select_list_spec.rb +320 -0
- data/spec/select_lists_spec.rb +47 -0
- data/spec/span_spec.rb +184 -0
- data/spec/spans_spec.rb +64 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +66 -0
- data/spec/strong_spec.rb +101 -0
- data/spec/strongs_spec.rb +40 -0
- data/spec/table_bodies_spec.rb +57 -0
- data/spec/table_body_spec.rb +109 -0
- data/spec/table_cell_spec.rb +84 -0
- data/spec/table_cells_spec.rb +59 -0
- data/spec/table_footer_spec.rb +96 -0
- data/spec/table_footers_spec.rb +55 -0
- data/spec/table_header_spec.rb +101 -0
- data/spec/table_headers_spec.rb +55 -0
- data/spec/table_row_spec.rb +106 -0
- data/spec/table_rows_spec.rb +58 -0
- data/spec/table_spec.rb +169 -0
- data/spec/tables_spec.rb +42 -0
- data/spec/text_field_spec.rb +331 -0
- data/spec/text_fields_spec.rb +44 -0
- data/spec/ul_spec.rb +88 -0
- data/spec/uls_spec.rb +40 -0
- data/spec/watir_compatibility_spec.rb +268 -0
- data/support/spec_server.rb +122 -0
- data/tasks/benchmark.rake +4 -0
- data/tasks/deployment.rake +43 -0
- data/tasks/environment.rake +7 -0
- data/tasks/fix.rake +25 -0
- data/tasks/rspec.rake +31 -0
- data/tasks/simple_ci.rake +94 -0
- data/tasks/snapshot.rake +22 -0
- data/tasks/specserver.rake +21 -0
- data/tasks/website.rake +17 -0
- data/tasks/yard.rake +9 -0
- data/website/benchmarks.html +237 -0
- data/website/css/color.css +153 -0
- data/website/css/hacks.css +3 -0
- data/website/css/layout.css +179 -0
- data/website/css/screen.css +5 -0
- data/website/css/textmate.css +226 -0
- data/website/css/typography.css +72 -0
- data/website/gfx/body_bg.gif +0 -0
- data/website/gfx/button_bg.jpg +0 -0
- data/website/gfx/header_bg.jpg +0 -0
- data/website/gfx/header_left.jpg +0 -0
- data/website/gfx/header_right.jpg +0 -0
- data/website/gfx/nav_bg.jpg +0 -0
- data/website/index.html +133 -0
- data/website/yard/Celerity.html +50 -0
- data/website/yard/Celerity/Area.html +212 -0
- data/website/yard/Celerity/Areas.html +103 -0
- data/website/yard/Celerity/Browser.html +5594 -0
- data/website/yard/Celerity/Button.html +312 -0
- data/website/yard/Celerity/Buttons.html +103 -0
- data/website/yard/Celerity/CheckBox.html +347 -0
- data/website/yard/Celerity/CheckBoxes.html +103 -0
- data/website/yard/Celerity/ClickableElement.html +448 -0
- data/website/yard/Celerity/Container.html +7676 -0
- data/website/yard/Celerity/Dd.html +198 -0
- data/website/yard/Celerity/Dds.html +103 -0
- data/website/yard/Celerity/DefaultViewer.html +101 -0
- data/website/yard/Celerity/DisabledElement.html +252 -0
- data/website/yard/Celerity/Div.html +198 -0
- data/website/yard/Celerity/Divs.html +103 -0
- data/website/yard/Celerity/Dl.html +198 -0
- data/website/yard/Celerity/Dls.html +103 -0
- data/website/yard/Celerity/Dt.html +198 -0
- data/website/yard/Celerity/Dts.html +103 -0
- data/website/yard/Celerity/Element.html +1703 -0
- data/website/yard/Celerity/ElementCollection.html +725 -0
- data/website/yard/Celerity/ElementLocator.html +589 -0
- data/website/yard/Celerity/Em.html +198 -0
- data/website/yard/Celerity/Ems.html +103 -0
- data/website/yard/Celerity/Exception.html +23 -0
- data/website/yard/Celerity/Exception/CelerityException.html +32 -0
- data/website/yard/Celerity/Exception/MissingWayOfFindingObjectException.html +32 -0
- data/website/yard/Celerity/Exception/NavigationException.html +33 -0
- data/website/yard/Celerity/Exception/NoValueFoundException.html +33 -0
- data/website/yard/Celerity/Exception/ObjectDisabledException.html +33 -0
- data/website/yard/Celerity/Exception/ObjectReadOnlyException.html +33 -0
- data/website/yard/Celerity/Exception/UnexpectedPageException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownCellException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownFormException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownFrameException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownObjectException.html +33 -0
- data/website/yard/Celerity/Exception/UnknownRowException.html +33 -0
- data/website/yard/Celerity/FileField.html +289 -0
- data/website/yard/Celerity/FileFields.html +103 -0
- data/website/yard/Celerity/Form.html +284 -0
- data/website/yard/Celerity/Forms.html +103 -0
- data/website/yard/Celerity/Frame.html +527 -0
- data/website/yard/Celerity/Frames.html +103 -0
- data/website/yard/Celerity/H1.html +198 -0
- data/website/yard/Celerity/H1s.html +103 -0
- data/website/yard/Celerity/H2.html +198 -0
- data/website/yard/Celerity/H2s.html +103 -0
- data/website/yard/Celerity/H3.html +198 -0
- data/website/yard/Celerity/H3s.html +103 -0
- data/website/yard/Celerity/H4.html +198 -0
- data/website/yard/Celerity/H4s.html +103 -0
- data/website/yard/Celerity/H5.html +198 -0
- data/website/yard/Celerity/H5s.html +103 -0
- data/website/yard/Celerity/H6.html +198 -0
- data/website/yard/Celerity/H6s.html +103 -0
- data/website/yard/Celerity/Hidden.html +285 -0
- data/website/yard/Celerity/Hiddens.html +103 -0
- data/website/yard/Celerity/Image.html +645 -0
- data/website/yard/Celerity/Images.html +103 -0
- data/website/yard/Celerity/InputElement.html +271 -0
- data/website/yard/Celerity/Label.html +210 -0
- data/website/yard/Celerity/Labels.html +103 -0
- data/website/yard/Celerity/Li.html +198 -0
- data/website/yard/Celerity/Link.html +295 -0
- data/website/yard/Celerity/Links.html +103 -0
- data/website/yard/Celerity/Lis.html +103 -0
- data/website/yard/Celerity/Listener.html +821 -0
- data/website/yard/Celerity/Map.html +198 -0
- data/website/yard/Celerity/Maps.html +103 -0
- data/website/yard/Celerity/Meta.html +196 -0
- data/website/yard/Celerity/Metas.html +103 -0
- data/website/yard/Celerity/MethodGenerator.html +195 -0
- data/website/yard/Celerity/NonControlElement.html +212 -0
- data/website/yard/Celerity/Ol.html +198 -0
- data/website/yard/Celerity/Ols.html +103 -0
- data/website/yard/Celerity/Option.html +348 -0
- data/website/yard/Celerity/Options.html +103 -0
- data/website/yard/Celerity/P.html +198 -0
- data/website/yard/Celerity/Pre.html +198 -0
- data/website/yard/Celerity/Pres.html +103 -0
- data/website/yard/Celerity/Ps.html +103 -0
- data/website/yard/Celerity/Radio.html +339 -0
- data/website/yard/Celerity/RadioCheckCommon.html +453 -0
- data/website/yard/Celerity/Radios.html +103 -0
- data/website/yard/Celerity/SelectList.html +1122 -0
- data/website/yard/Celerity/SelectLists.html +103 -0
- data/website/yard/Celerity/ShortInspect.html +108 -0
- data/website/yard/Celerity/Span.html +198 -0
- data/website/yard/Celerity/Spans.html +103 -0
- data/website/yard/Celerity/Strong.html +198 -0
- data/website/yard/Celerity/Strongs.html +103 -0
- data/website/yard/Celerity/Table.html +1287 -0
- data/website/yard/Celerity/TableBodies.html +103 -0
- data/website/yard/Celerity/TableBody.html +203 -0
- data/website/yard/Celerity/TableCell.html +279 -0
- data/website/yard/Celerity/TableCells.html +103 -0
- data/website/yard/Celerity/TableElement.html +437 -0
- data/website/yard/Celerity/TableFooter.html +203 -0
- data/website/yard/Celerity/TableFooters.html +103 -0
- data/website/yard/Celerity/TableHeader.html +203 -0
- data/website/yard/Celerity/TableHeaders.html +103 -0
- data/website/yard/Celerity/TableRow.html +478 -0
- data/website/yard/Celerity/TableRows.html +103 -0
- data/website/yard/Celerity/Tables.html +103 -0
- data/website/yard/Celerity/TextField.html +938 -0
- data/website/yard/Celerity/TextFields.html +103 -0
- data/website/yard/Celerity/Th.html +208 -0
- data/website/yard/Celerity/Ul.html +209 -0
- data/website/yard/Celerity/Uls.html +103 -0
- data/website/yard/Celerity/Util.html +264 -0
- data/website/yard/Celerity/VERSION.html +44 -0
- data/website/yard/HtmlUnit.html +23 -0
- data/website/yard/HtmlUnit/Html.html +23 -0
- data/website/yard/HtmlUnit/Util.html +23 -0
- data/website/yard/Java/ComGargoylesoftwareHtmlunitHtml/HtmlPage.html +90 -0
- data/website/yard/Java/JavaLang/Iterable.html +103 -0
- data/website/yard/Java/OrgW3cDom/NamedNodeMap.html +97 -0
- data/website/yard/README.txt.html +116 -0
- data/website/yard/String.html +103 -0
- data/website/yard/all-files.html +22 -0
- data/website/yard/all-methods.html +3276 -0
- data/website/yard/all-namespaces.html +258 -0
- data/website/yard/app.js +18 -0
- data/website/yard/index.html +19 -0
- data/website/yard/jquery.js +11 -0
- data/website/yard/style.css +68 -0
- data/website/yard/syntax_highlight.css +21 -0
- metadata +285 -13
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/loader"
|
2
|
+
|
3
|
+
browser = create_browser
|
4
|
+
browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
5
|
+
|
6
|
+
TESTS = 10000
|
7
|
+
res = Benchmark.bmbm do |results|
|
8
|
+
results.report("TextField#set") do
|
9
|
+
TESTS.times { browser.text_field(:id, "new_user_first_name").set("1234567890") }
|
10
|
+
end
|
11
|
+
results.report("TextField#value=") do
|
12
|
+
TESTS.times { browser.text_field(:id, "new_user_first_name").value = "1234567890" }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
puts
|
17
|
+
total = res.inject(0.0) { |mem, bm| mem + bm.real }
|
18
|
+
puts "total : " + total.to_s
|
19
|
+
puts "average: " + (total/res.size.to_f).to_s
|
data/benchmark/loader.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require File.dirname(__FILE__) + "/../spec/spec_helper"
|
3
|
+
|
4
|
+
|
5
|
+
def create_browser
|
6
|
+
if RUBY_PLATFORM =~ /java/
|
7
|
+
browser = Celerity::Browser.new(:log_level => :off)
|
8
|
+
else
|
9
|
+
require 'watir'
|
10
|
+
browser = Watir::IE.new
|
11
|
+
end
|
12
|
+
|
13
|
+
browser
|
14
|
+
end
|
data/celerity.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{celerity}
|
5
|
+
s.version = "0.0.6.11"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Jari Bakken", "T. Alexander Lystad", "Knut Johannes Dahle"]
|
9
|
+
s.date = %q{2009-06-26}
|
10
|
+
s.description = %q{Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with JavaScript support. It provides a simple API for programmatic navigation through web applications. Celerity aims at being API compatible with Watir.}
|
11
|
+
s.email = %q{jari.bakken@finn.no}
|
12
|
+
s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt"]
|
13
|
+
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "benchmark/bm_2000_spans.rb", "benchmark/bm_digg.rb", "benchmark/bm_google_images.rb", "benchmark/bm_input_locator.rb", "benchmark/bm_text_input.rb", "benchmark/loader.rb", "celerity.gemspec", "config/hoe.rb", "config/requirements.rb", "lib/celerity.rb", "lib/celerity/browser.rb", "lib/celerity/clickable_element.rb", "lib/celerity/collections.rb", "lib/celerity/container.rb", "lib/celerity/default_viewer.rb", "lib/celerity/disabled_element.rb", "lib/celerity/element.rb", "lib/celerity/element_collection.rb", "lib/celerity/element_locator.rb", "lib/celerity/elements/button.rb", "lib/celerity/elements/file_field.rb", "lib/celerity/elements/form.rb", "lib/celerity/elements/frame.rb", "lib/celerity/elements/image.rb", "lib/celerity/elements/label.rb", "lib/celerity/elements/link.rb", "lib/celerity/elements/meta.rb", "lib/celerity/elements/non_control_elements.rb", "lib/celerity/elements/option.rb", "lib/celerity/elements/radio_check.rb", "lib/celerity/elements/select_list.rb", "lib/celerity/elements/table.rb", "lib/celerity/elements/table_cell.rb", "lib/celerity/elements/table_elements.rb", "lib/celerity/elements/table_row.rb", "lib/celerity/elements/text_field.rb", "lib/celerity/exception.rb", "lib/celerity/htmlunit.rb", "lib/celerity/htmlunit/commons-codec-1.3.jar", "lib/celerity/htmlunit/commons-collections-3.2.1.jar", "lib/celerity/htmlunit/commons-httpclient-3.1.jar", "lib/celerity/htmlunit/commons-io-1.4.jar", "lib/celerity/htmlunit/commons-lang-2.4.jar", "lib/celerity/htmlunit/commons-logging-1.1.1.jar", "lib/celerity/htmlunit/cssparser-0.9.5.jar", "lib/celerity/htmlunit/htmlunit-2.6-SNAPSHOT.jar", "lib/celerity/htmlunit/htmlunit-core-js-2.5.jar", "lib/celerity/htmlunit/nekohtml-1.9.13-20090507.082850-2.jar", "lib/celerity/htmlunit/sac-1.3.jar", "lib/celerity/htmlunit/serializer-2.7.1.jar", "lib/celerity/htmlunit/xalan-2.7.1.jar", "lib/celerity/htmlunit/xercesImpl-2.8.1.jar", "lib/celerity/htmlunit/xml-apis-1.3.04.jar", "lib/celerity/identifier.rb", "lib/celerity/input_element.rb", "lib/celerity/listener.rb", "lib/celerity/resources/no_viewer.png", "lib/celerity/short_inspect.rb", "lib/celerity/util.rb", "lib/celerity/version.rb", "lib/celerity/watir_compatibility.rb", "spec/area_spec.rb", "spec/areas_spec.rb", "spec/browser_authentication_spec.rb", "spec/browser_spec.rb", "spec/button_spec.rb", "spec/buttons_spec.rb", "spec/checkbox_spec.rb", "spec/checkboxes_spec.rb", "spec/clickable_element_spec.rb", "spec/dd_spec.rb", "spec/dds_spec.rb", "spec/default_viewer_spec.rb", "spec/div_spec.rb", "spec/divs_spec.rb", "spec/dl_spec.rb", "spec/dls_spec.rb", "spec/dt_spec.rb", "spec/dts_spec.rb", "spec/element_spec.rb", "spec/em_spec.rb", "spec/ems_spec.rb", "spec/filefield_spec.rb", "spec/filefields_spec.rb", "spec/form_spec.rb", "spec/forms_spec.rb", "spec/frame_spec.rb", "spec/frames_spec.rb", "spec/hidden_spec.rb", "spec/hiddens_spec.rb", "spec/hn_spec.rb", "spec/hns_spec.rb", "spec/html/2000_spans.html", "spec/html/bug_duplicate_attributes.html", "spec/html/bug_javascript_001.html", "spec/html/definition_lists.html", "spec/html/euc-jp_text.html", "spec/html/forms_with_input_elements.html", "spec/html/frame_1.html", "spec/html/frame_2.html", "spec/html/frames.html", "spec/html/iframes.html", "spec/html/images.html", "spec/html/images/1.gif", "spec/html/images/2.gif", "spec/html/images/3.gif", "spec/html/images/button.jpg", "spec/html/images/circle.jpg", "spec/html/images/map.gif", "spec/html/images/map2.gif", "spec/html/images/minus.gif", "spec/html/images/originaltriangle.jpg", "spec/html/images/plus.gif", "spec/html/images/square.jpg", "spec/html/images/triangle.jpg", "spec/html/iso-2022-jp_text.html", "spec/html/jquery.html", "spec/html/latin1_text.html", "spec/html/multiple_ids.html", "spec/html/non_control_elements.html", "spec/html/right_click.html", "spec/html/shift_jis_text.html", "spec/html/tables.html", "spec/html/timeout.html", "spec/html/tiny_mce.html", "spec/html/utf8_text.html", "spec/htmlunit_spec.rb", "spec/image_spec.rb", "spec/images_spec.rb", "spec/index_offset_spec.rb", "spec/label_spec.rb", "spec/labels_spec.rb", "spec/li_spec.rb", "spec/link_spec.rb", "spec/links_spec.rb", "spec/lis_spec.rb", "spec/listener_spec.rb", "spec/map_spec.rb", "spec/maps_spec.rb", "spec/meta_spec.rb", "spec/metas_spec.rb", "spec/ol_spec.rb", "spec/ols_spec.rb", "spec/option_spec.rb", "spec/p_spec.rb", "spec/pre_spec.rb", "spec/pres_spec.rb", "spec/ps_spec.rb", "spec/radio_spec.rb", "spec/radios_spec.rb", "spec/select_list_spec.rb", "spec/select_lists_spec.rb", "spec/span_spec.rb", "spec/spans_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/strong_spec.rb", "spec/strongs_spec.rb", "spec/table_bodies_spec.rb", "spec/table_body_spec.rb", "spec/table_cell_spec.rb", "spec/table_cells_spec.rb", "spec/table_footer_spec.rb", "spec/table_footers_spec.rb", "spec/table_header_spec.rb", "spec/table_headers_spec.rb", "spec/table_row_spec.rb", "spec/table_rows_spec.rb", "spec/table_spec.rb", "spec/tables_spec.rb", "spec/text_field_spec.rb", "spec/text_fields_spec.rb", "spec/ul_spec.rb", "spec/uls_spec.rb", "spec/watir_compatibility_spec.rb", "support/spec_server.rb", "tasks/benchmark.rake", "tasks/deployment.rake", "tasks/environment.rake", "tasks/fix.rake", "tasks/jar.rake", "tasks/rdoc.rake", "tasks/rspec.rake", "tasks/simple_ci.rake", "tasks/snapshot.rake", "tasks/specserver.rake", "tasks/website.rake", "tasks/yard.rake", "website/benchmarks.html", "website/css/color.css", "website/css/hacks.css", "website/css/layout.css", "website/css/screen.css", "website/css/textmate.css", "website/css/typography.css", "website/gfx/body_bg.gif", "website/gfx/button_bg.jpg", "website/gfx/header_bg.jpg", "website/gfx/header_left.jpg", "website/gfx/header_right.jpg", "website/gfx/nav_bg.jpg", "website/index.html", "website/yard/Celerity.html", "website/yard/Celerity/Area.html", "website/yard/Celerity/Areas.html", "website/yard/Celerity/Browser.html", "website/yard/Celerity/Button.html", "website/yard/Celerity/Buttons.html", "website/yard/Celerity/CheckBox.html", "website/yard/Celerity/CheckBoxes.html", "website/yard/Celerity/ClickableElement.html", "website/yard/Celerity/Container.html", "website/yard/Celerity/Dd.html", "website/yard/Celerity/Dds.html", "website/yard/Celerity/DefaultViewer.html", "website/yard/Celerity/DisabledElement.html", "website/yard/Celerity/Div.html", "website/yard/Celerity/Divs.html", "website/yard/Celerity/Dl.html", "website/yard/Celerity/Dls.html", "website/yard/Celerity/Dt.html", "website/yard/Celerity/Dts.html", "website/yard/Celerity/Element.html", "website/yard/Celerity/ElementCollection.html", "website/yard/Celerity/ElementLocator.html", "website/yard/Celerity/Em.html", "website/yard/Celerity/Ems.html", "website/yard/Celerity/Exception.html", "website/yard/Celerity/Exception/CelerityException.html", "website/yard/Celerity/Exception/MissingWayOfFindingObjectException.html", "website/yard/Celerity/Exception/NavigationException.html", "website/yard/Celerity/Exception/NoValueFoundException.html", "website/yard/Celerity/Exception/ObjectDisabledException.html", "website/yard/Celerity/Exception/ObjectReadOnlyException.html", "website/yard/Celerity/Exception/UnexpectedPageException.html", "website/yard/Celerity/Exception/UnknownCellException.html", "website/yard/Celerity/Exception/UnknownFormException.html", "website/yard/Celerity/Exception/UnknownFrameException.html", "website/yard/Celerity/Exception/UnknownObjectException.html", "website/yard/Celerity/Exception/UnknownRowException.html", "website/yard/Celerity/FileField.html", "website/yard/Celerity/FileFields.html", "website/yard/Celerity/Form.html", "website/yard/Celerity/Forms.html", "website/yard/Celerity/Frame.html", "website/yard/Celerity/Frames.html", "website/yard/Celerity/H1.html", "website/yard/Celerity/H1s.html", "website/yard/Celerity/H2.html", "website/yard/Celerity/H2s.html", "website/yard/Celerity/H3.html", "website/yard/Celerity/H3s.html", "website/yard/Celerity/H4.html", "website/yard/Celerity/H4s.html", "website/yard/Celerity/H5.html", "website/yard/Celerity/H5s.html", "website/yard/Celerity/H6.html", "website/yard/Celerity/H6s.html", "website/yard/Celerity/Hidden.html", "website/yard/Celerity/Hiddens.html", "website/yard/Celerity/Image.html", "website/yard/Celerity/Images.html", "website/yard/Celerity/InputElement.html", "website/yard/Celerity/Label.html", "website/yard/Celerity/Labels.html", "website/yard/Celerity/Li.html", "website/yard/Celerity/Link.html", "website/yard/Celerity/Links.html", "website/yard/Celerity/Lis.html", "website/yard/Celerity/Listener.html", "website/yard/Celerity/Map.html", "website/yard/Celerity/Maps.html", "website/yard/Celerity/Meta.html", "website/yard/Celerity/Metas.html", "website/yard/Celerity/MethodGenerator.html", "website/yard/Celerity/NonControlElement.html", "website/yard/Celerity/Ol.html", "website/yard/Celerity/Ols.html", "website/yard/Celerity/Option.html", "website/yard/Celerity/Options.html", "website/yard/Celerity/P.html", "website/yard/Celerity/Pre.html", "website/yard/Celerity/Pres.html", "website/yard/Celerity/Ps.html", "website/yard/Celerity/Radio.html", "website/yard/Celerity/RadioCheckCommon.html", "website/yard/Celerity/Radios.html", "website/yard/Celerity/SelectList.html", "website/yard/Celerity/SelectLists.html", "website/yard/Celerity/ShortInspect.html", "website/yard/Celerity/Span.html", "website/yard/Celerity/Spans.html", "website/yard/Celerity/Strong.html", "website/yard/Celerity/Strongs.html", "website/yard/Celerity/Table.html", "website/yard/Celerity/TableBodies.html", "website/yard/Celerity/TableBody.html", "website/yard/Celerity/TableCell.html", "website/yard/Celerity/TableCells.html", "website/yard/Celerity/TableElement.html", "website/yard/Celerity/TableFooter.html", "website/yard/Celerity/TableFooters.html", "website/yard/Celerity/TableHeader.html", "website/yard/Celerity/TableHeaders.html", "website/yard/Celerity/TableRow.html", "website/yard/Celerity/TableRows.html", "website/yard/Celerity/Tables.html", "website/yard/Celerity/TextField.html", "website/yard/Celerity/TextFields.html", "website/yard/Celerity/Th.html", "website/yard/Celerity/Ul.html", "website/yard/Celerity/Uls.html", "website/yard/Celerity/Util.html", "website/yard/Celerity/VERSION.html", "website/yard/HtmlUnit.html", "website/yard/HtmlUnit/Html.html", "website/yard/HtmlUnit/Util.html", "website/yard/Java/ComGargoylesoftwareHtmlunitHtml/HtmlPage.html", "website/yard/Java/JavaLang/Iterable.html", "website/yard/Java/OrgW3cDom/NamedNodeMap.html", "website/yard/README.txt.html", "website/yard/String.html", "website/yard/all-files.html", "website/yard/all-methods.html", "website/yard/all-namespaces.html", "website/yard/app.js", "website/yard/index.html", "website/yard/jquery.js", "website/yard/style.css", "website/yard/syntax_highlight.css"]
|
14
|
+
s.homepage = %q{http://celerity.rubyforge.org}
|
15
|
+
s.rdoc_options = ["--main", "README.txt"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{celerity}
|
18
|
+
s.rubygems_version = %q{1.3.4}
|
19
|
+
s.summary = %q{Celerity is a JRuby library for easy and fast functional test automation for web applications}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_development_dependency(%q<hoe>, [">= 2.0.0"])
|
27
|
+
else
|
28
|
+
s.add_dependency(%q<hoe>, [">= 2.0.0"])
|
29
|
+
end
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<hoe>, [">= 2.0.0"])
|
32
|
+
end
|
33
|
+
end
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'celerity/version'
|
2
|
+
|
3
|
+
AUTHORS = ["Jari Bakken", "T. Alexander Lystad", "Knut Johannes Dahle"]
|
4
|
+
EMAIL = "jari.bakken@finn.no"
|
5
|
+
DESCRIPTION = "Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with JavaScript support. It provides a simple API for programmatic navigation through web applications. Celerity aims at being API compatible with Watir."
|
6
|
+
SUMMARY = "Celerity is a JRuby library for easy and fast functional test automation for web applications"
|
7
|
+
GEM_NAME = 'celerity'
|
8
|
+
RUBYFORGE_PROJECT = 'celerity'
|
9
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
10
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
11
|
+
|
12
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
13
|
+
@config = nil
|
14
|
+
RUBYFORGE_USERNAME = "unknown"
|
15
|
+
|
16
|
+
def rubyforge_username
|
17
|
+
unless @config
|
18
|
+
begin
|
19
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
20
|
+
rescue
|
21
|
+
puts <<-EOS
|
22
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
23
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
24
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
25
|
+
EOS
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
end
|
29
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
REV = nil
|
34
|
+
# UNCOMMENT IF REQUIRED:
|
35
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
36
|
+
VERS = Celerity::VERSION::STRING
|
37
|
+
|
38
|
+
class Hoe
|
39
|
+
def extra_deps
|
40
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
41
|
+
@extra_deps
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Generate all the Rake tasks
|
46
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
47
|
+
$hoe = Hoe.spec(GEM_NAME) do |p|
|
48
|
+
p.version = VERS
|
49
|
+
p.author = AUTHORS
|
50
|
+
p.email = EMAIL
|
51
|
+
p.description = DESCRIPTION
|
52
|
+
p.summary = SUMMARY
|
53
|
+
p.url = HOMEPATH
|
54
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
55
|
+
p.test_globs = ["test/**/test_*.rb"]
|
56
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store', 'classes'] #An array of file patterns to delete on clean.
|
57
|
+
|
58
|
+
# == Optional
|
59
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
60
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
61
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
66
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
67
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
68
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
69
|
+
|
70
|
+
namespace :gem do
|
71
|
+
desc "create a gemspec file"
|
72
|
+
task :make_spec do
|
73
|
+
file = "#{GEM_NAME.downcase}.gemspec"
|
74
|
+
File.open(file, "w") do |file|
|
75
|
+
file.puts $hoe.spec.to_ruby
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/celerity/version.rb
CHANGED
data/spec/area_spec.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Area" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/images.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
# Exists method
|
14
|
+
describe "#exist?" do
|
15
|
+
it "returns true if the area exists" do
|
16
|
+
@browser.area(:id, "NCE").should exist
|
17
|
+
@browser.area(:id, /NCE/).should exist
|
18
|
+
@browser.area(:name, "NCE").should exist
|
19
|
+
@browser.area(:name, /NCE/).should exist
|
20
|
+
@browser.area(:title, "Tables").should exist
|
21
|
+
@browser.area(:title, /Tables/).should exist
|
22
|
+
@browser.area(:url, "tables.html").should exist
|
23
|
+
@browser.area(:url, /tables/).should exist
|
24
|
+
@browser.area(:index, 1).should exist
|
25
|
+
@browser.area(:xpath, "//area[@id='NCE']").should exist
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns true if the element exists (default how = :id)" do
|
29
|
+
@browser.area("NCE").should exist
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns false if the area doesn't exist" do
|
33
|
+
@browser.area(:id, "no_such_id").should_not exist
|
34
|
+
@browser.area(:id, /no_such_id/).should_not exist
|
35
|
+
@browser.area(:name, "no_such_id").should_not exist
|
36
|
+
@browser.area(:name, /no_such_id/).should_not exist
|
37
|
+
@browser.area(:title, "no_such_title").should_not exist
|
38
|
+
@browser.area(:title, /no_such_title/).should_not exist
|
39
|
+
@browser.area(:url, "no_such_href").should_not exist
|
40
|
+
@browser.area(:url, /no_such_href/).should_not exist
|
41
|
+
@browser.area(:index, 1337).should_not exist
|
42
|
+
@browser.area(:xpath, "//area[@id='no_such_id']").should_not exist
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raises TypeError when 'what' argument is invalid" do
|
46
|
+
lambda { @browser.area(:id, 3.14).exists? }.should raise_error(TypeError)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
50
|
+
lambda { @browser.area(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Attribute methods
|
55
|
+
describe "#id" do
|
56
|
+
it "returns the id attribute" do
|
57
|
+
@browser.area(:index, 1).id.should == "NCE"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
61
|
+
@browser.area(:index, 3).id.should == ''
|
62
|
+
end
|
63
|
+
|
64
|
+
it "raises UnknownObjectException if the area doesn't exist" do
|
65
|
+
lambda { @browser.area(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
66
|
+
lambda { @browser.area(:index, 1337).id }.should raise_error(UnknownObjectException)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#name" do
|
72
|
+
it "returns the name attribute" do
|
73
|
+
@browser.area(:index, 1).name.should == "NCE"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
77
|
+
@browser.area(:index, 3).name.should == ''
|
78
|
+
end
|
79
|
+
|
80
|
+
it "raises UnknownObjectException if the area doesn't exist" do
|
81
|
+
lambda { @browser.area(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
82
|
+
lambda { @browser.area(:index, 1337).name }.should raise_error(UnknownObjectException)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#respond_to?" do
|
87
|
+
it "returns true for all attribute methods" do
|
88
|
+
@browser.area(:index, 1).should respond_to(:id)
|
89
|
+
@browser.area(:index, 1).should respond_to(:name)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
after :all do
|
94
|
+
@browser.close
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
data/spec/areas_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Areas" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/images.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#length" do
|
14
|
+
it "returns the number of areas" do
|
15
|
+
@browser.areas.length.should == 3
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#[]" do
|
20
|
+
it "returns the area at the given index" do
|
21
|
+
@browser.areas[1].id.should == "NCE"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#each" do
|
26
|
+
it "iterates through areas correctly" do
|
27
|
+
@browser.areas.each_with_index do |a, index|
|
28
|
+
a.name.should == @browser.area(:index, index+1).name
|
29
|
+
a.id.should == @browser.area(:index, index+1).id
|
30
|
+
a.value.should == @browser.area(:index, index+1).value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
after :all do
|
36
|
+
@browser.close
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Browser" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(:log_level => :off)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#credentials=" do
|
10
|
+
it "sets the basic authentication credentials" do
|
11
|
+
@browser.goto(TEST_HOST + "/authentication/")
|
12
|
+
@browser.text.should_not include("Index of /authentication/")
|
13
|
+
|
14
|
+
@browser.credentials = "foo:bar"
|
15
|
+
|
16
|
+
@browser.goto(TEST_HOST + "/authentication/")
|
17
|
+
@browser.text.should include("Index of /authentication/")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,537 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Browser" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#new" do
|
10
|
+
it "raises TypeError if argument is not a Hash" do
|
11
|
+
lambda { Browser.new(:foo) }.should raise_error(TypeError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "raises ArgumentError if given bad arguments for :render key" do
|
15
|
+
lambda { Browser.new(:render => :foo) }.should raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "raises ArgumentError if given bad arguments for :browser key" do
|
19
|
+
lambda { Browser.new(:browser => 'foo') }.should raise_error(ArgumentError)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "raises ArgumentError if given an unknown option" do
|
23
|
+
lambda { Browser.new(:foo => 1) }.should raise_error(ArgumentError)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should hold the init options" do
|
27
|
+
@browser.options.should == BROWSER_OPTIONS
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should use the specified proxy" do
|
31
|
+
received = false
|
32
|
+
blk = lambda { received = true }
|
33
|
+
s = WEBrick::HTTPProxyServer.new(:Port => 2001, :ProxyContentHandler => blk)
|
34
|
+
Thread.new { s.start }
|
35
|
+
|
36
|
+
b = Browser.new(:proxy => "localhost:2001")
|
37
|
+
b.goto(TEST_HOST)
|
38
|
+
s.shutdown
|
39
|
+
|
40
|
+
received.should be_true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should use the specified user agent" do
|
44
|
+
b = Browser.new(BROWSER_OPTIONS.merge(:user_agent => "Celerity"))
|
45
|
+
b.goto(TEST_HOST + "/header_echo")
|
46
|
+
b.text.should include(%q["user-agent"=>["Celerity"]])
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#exists?" do
|
52
|
+
it "returns true if we are at a page" do
|
53
|
+
@browser.should_not exist
|
54
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
55
|
+
@browser.should exist
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns false after IE#close" do
|
59
|
+
@browser.close
|
60
|
+
@browser.should_not exist
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#html" do
|
65
|
+
it "returns the html of the page" do
|
66
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
67
|
+
@browser.html.should == File.read(File.dirname(__FILE__) + "/html/non_control_elements.html")
|
68
|
+
end
|
69
|
+
|
70
|
+
%w(shift_jis iso-2022-jp euc-jp).each do |charset|
|
71
|
+
it "returns decoded #{charset.upcase} when :charset specified" do
|
72
|
+
browser = Browser.new(:charset => charset.upcase)
|
73
|
+
browser.goto(HTML_DIR + "/#{charset}_text.html")
|
74
|
+
browser.html.should =~ /本日は晴天なり。/ # Browser#text is automagically transcoded into the right charset, but Browser#html isn't.
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "#title" do
|
80
|
+
it "returns the current page title" do
|
81
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
82
|
+
@browser.title.should == "Non-control elements"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#status" do
|
87
|
+
it "returns the current value of window.status" do
|
88
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
89
|
+
@browser.execute_script "window.status = 'All done!';"
|
90
|
+
@browser.status.should == "All done!"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "#text" do
|
95
|
+
it "returns the text of the page" do
|
96
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
97
|
+
@browser.text.should include("Dubito, ergo cogito, ergo sum.")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "returns the text also if the content-type is text/plain" do
|
101
|
+
# more specs for text/plain? what happens if we call other methods?
|
102
|
+
@browser.goto(TEST_HOST + "/plain_text")
|
103
|
+
@browser.text.strip.should == 'This is text/plain'
|
104
|
+
end
|
105
|
+
|
106
|
+
# disabled for CI - need fix from HtmlUnit
|
107
|
+
# it "returns a text representation including newlines" do
|
108
|
+
# @browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
109
|
+
# @browser.text.should == <<-TEXT
|
110
|
+
# Forms with input elementsUser administration
|
111
|
+
#
|
112
|
+
# Add user
|
113
|
+
#
|
114
|
+
# Personal informationFirst name
|
115
|
+
#
|
116
|
+
# Last name
|
117
|
+
#
|
118
|
+
# Email address
|
119
|
+
#
|
120
|
+
# Country Denmark Norway Sweden United Kingdom USA
|
121
|
+
#
|
122
|
+
# Occupation
|
123
|
+
#
|
124
|
+
# Species
|
125
|
+
#
|
126
|
+
# Personal code
|
127
|
+
#
|
128
|
+
# Languages Danish English Norwegian Swedish
|
129
|
+
#
|
130
|
+
# Portrait
|
131
|
+
#
|
132
|
+
# Dental records Login informationUsername (max 20 characters) 0
|
133
|
+
#
|
134
|
+
# Password
|
135
|
+
#
|
136
|
+
# Role Administrator Moderator Regular user Interests Books Bowling Cars Dancing Dentistry Food Preferences
|
137
|
+
#
|
138
|
+
# Do you want to recieve our newslettter?
|
139
|
+
#
|
140
|
+
# Yes No Certainly Absolutely Nah Actions Button 2
|
141
|
+
#
|
142
|
+
# Delete user
|
143
|
+
#
|
144
|
+
# Username Username 1 Username 2 Username 3
|
145
|
+
#
|
146
|
+
# Comment Default comment.
|
147
|
+
# TEXT
|
148
|
+
# end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "#url" do
|
152
|
+
it "returns the current url" do
|
153
|
+
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
154
|
+
@browser.url.should == TEST_HOST + "/non_control_elements.html"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "#document" do
|
159
|
+
it "returns the underlying object" do
|
160
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
161
|
+
if RUBY_PLATFORM =~ /java/
|
162
|
+
@browser.document.should be_instance_of(Java::ComGargoylesoftwareHtmlunitHtml::HtmlHtml)
|
163
|
+
else
|
164
|
+
@browser.document.should be_instance_of(WIN32OLE)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "#response_headers" do
|
170
|
+
it "returns the response headers (as a hash)" do
|
171
|
+
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
172
|
+
@browser.response_headers.should be_kind_of(Hash)
|
173
|
+
@browser.response_headers['Date'].should be_kind_of(String)
|
174
|
+
@browser.response_headers['Content-Type'].should be_kind_of(String)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "#content_type" do
|
179
|
+
it "returns the content type" do
|
180
|
+
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
181
|
+
@browser.content_type.should =~ /\w+\/\w+/
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
describe "#io" do
|
187
|
+
it "returns the io object of the content" do
|
188
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
189
|
+
@browser.io.should be_kind_of(IO)
|
190
|
+
@browser.io.read.should == File.read("#{File.dirname(__FILE__)}/html/non_control_elements.html")
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
# Manipulation methods
|
196
|
+
describe ".start" do
|
197
|
+
it "goes to the given URL and return an instance of itself" do
|
198
|
+
@browser = Browser.start(HTML_DIR + "/non_control_elements.html")
|
199
|
+
@browser.should be_instance_of(Browser)
|
200
|
+
@browser.title.should == "Non-control elements"
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe "#goto" do
|
205
|
+
it "adds http:// to URLs with no protocol specified" do
|
206
|
+
url = TEST_HOST[%r{http://(.*)}, 1]
|
207
|
+
url.should_not be_nil
|
208
|
+
@browser.goto(url)
|
209
|
+
@browser.url.should =~ %r[http://#{url}/?]
|
210
|
+
end
|
211
|
+
|
212
|
+
it "goes to the given url without raising errors" do
|
213
|
+
lambda { @browser.goto(HTML_DIR + "/non_control_elements.html") }.should_not raise_error
|
214
|
+
end
|
215
|
+
|
216
|
+
it "raises UnexpectedPageException if the content type is not understood" do
|
217
|
+
lambda { @browser.goto(TEST_HOST + "/octet_stream") }.should raise_error(UnexpectedPageException)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "#refresh" do
|
222
|
+
it "refreshes the page" do
|
223
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
224
|
+
@browser.span(:name, 'footer').click
|
225
|
+
@browser.span(:name, 'footer').text.should include('Javascript')
|
226
|
+
@browser.refresh
|
227
|
+
@browser.span(:name, 'footer').text.should_not include('Javascript')
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "#execute_script" do
|
232
|
+
it "executes the given JavaScript on the current page" do
|
233
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
234
|
+
@browser.pre(:id, 'rspec').text.should_not == "javascript text"
|
235
|
+
@browser.execute_script("document.getElementById('rspec').innerHTML = 'javascript text'")
|
236
|
+
@browser.pre(:id, 'rspec').text.should == "javascript text"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
describe "#cookies" do
|
241
|
+
it "returns set cookies as a Ruby hash" do
|
242
|
+
cookies = @browser.cookies
|
243
|
+
cookies.should be_instance_of(Hash)
|
244
|
+
cookies.should be_empty
|
245
|
+
|
246
|
+
@browser.goto(TEST_HOST + "/set_cookie")
|
247
|
+
|
248
|
+
cookies = @browser.cookies
|
249
|
+
cookies.size.should == 1
|
250
|
+
cookies['localhost']['monster'].should == "/"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
describe "#clear_cookies" do
|
255
|
+
it "clears all cookies" do
|
256
|
+
@browser.cookies.should be_empty
|
257
|
+
@browser.goto(TEST_HOST + "/set_cookie")
|
258
|
+
@browser.cookies.size.should == 1
|
259
|
+
@browser.clear_cookies
|
260
|
+
@browser.cookies.should be_empty
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
describe "add_cookie" do
|
265
|
+
it "adds a cookie with the given domain, name and value" do
|
266
|
+
@browser.add_cookie("example.com", "foo", "bar")
|
267
|
+
cookies = @browser.cookies
|
268
|
+
cookies.should be_instance_of(Hash)
|
269
|
+
cookies.should have_key('example.com')
|
270
|
+
cookies['example.com']['foo'].should == 'bar'
|
271
|
+
|
272
|
+
@browser.clear_cookies
|
273
|
+
end
|
274
|
+
|
275
|
+
it "adds a cookie with the specified options" do
|
276
|
+
@browser.add_cookie("example.com", "foo", "bar", :path => "/foobar", :max_age => 1000)
|
277
|
+
cookies = @browser.cookies
|
278
|
+
cookies.should be_instance_of(Hash)
|
279
|
+
cookies['example.com']['foo'].should == 'bar'
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
describe "remove_cookie" do
|
284
|
+
it "removes the cookie for the given domain and name" do
|
285
|
+
@browser.goto(TEST_HOST + "/set_cookie")
|
286
|
+
@browser.remove_cookie("localhost", "monster")
|
287
|
+
@browser.cookies.should be_empty
|
288
|
+
end
|
289
|
+
|
290
|
+
it "raises an error if no such cookie exists" do
|
291
|
+
lambda { @browser.remove_cookie("bogus.com", "bar") }.should raise_error
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
describe "#back" do
|
296
|
+
it "goes to the previous page" do
|
297
|
+
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
298
|
+
orig_url = @browser.url
|
299
|
+
@browser.goto(TEST_HOST + "/tables.html")
|
300
|
+
new_url = @browser.url
|
301
|
+
orig_url.should_not == new_url
|
302
|
+
@browser.back
|
303
|
+
orig_url.should == @browser.url
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe "#wait" do
|
308
|
+
it "should wait for javascript timers to finish" do
|
309
|
+
alerts = 0
|
310
|
+
@browser.add_listener(:alert) { alerts += 1 }
|
311
|
+
@browser.goto(HTML_DIR + "/timeout.html")
|
312
|
+
@browser.div(:id, 'alert').click
|
313
|
+
@browser.wait.should be_true
|
314
|
+
alerts.should == 1
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
describe "#wait_while" do
|
319
|
+
it "waits until the specified condition becomes false" do
|
320
|
+
@browser.goto(HTML_DIR + "/timeout.html")
|
321
|
+
@browser.div(:id, "change").click
|
322
|
+
@browser.wait_while { @browser.contains_text("Trigger change") }
|
323
|
+
@browser.div(:id, "change").text.should == "all done"
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
describe "#wait_until" do
|
328
|
+
it "waits until the condition becomes true" do
|
329
|
+
@browser.goto(HTML_DIR + "/timeout.html")
|
330
|
+
@browser.div(:id, "change").click
|
331
|
+
@browser.wait_until { @browser.contains_text("all done") }
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
# Other
|
336
|
+
describe "#contains_text" do
|
337
|
+
before :each do
|
338
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
339
|
+
end
|
340
|
+
|
341
|
+
it "raises ArgumentError when called with no arguments" do
|
342
|
+
lambda { @browser.contains_text }.should raise_error(ArgumentError)
|
343
|
+
end
|
344
|
+
|
345
|
+
it "raises TypeError when called with wrong arguments" do
|
346
|
+
lambda { @browser.contains_text(nil) }.should raise_error(TypeError)
|
347
|
+
lambda { @browser.contains_text(42) }.should raise_error(TypeError)
|
348
|
+
end
|
349
|
+
|
350
|
+
it "returns the index if the given text exists" do
|
351
|
+
@browser.contains_text('Dubito, ergo cogito, ergo sum.').should be_instance_of(Fixnum)
|
352
|
+
@browser.contains_text(/Dubito.*sum./).should_not be_nil
|
353
|
+
end
|
354
|
+
|
355
|
+
it "returns nil if the text doesn't exist" do
|
356
|
+
@browser.contains_text('no_such_text').should be_nil
|
357
|
+
@browser.contains_text(/no_such_text/).should be_nil
|
358
|
+
end
|
359
|
+
|
360
|
+
it "does not raise error on a blank page" do
|
361
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
362
|
+
lambda { @browser.contains_text('') }.should_not raise_error
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
describe "#element_by_xpath" do
|
367
|
+
before :each do
|
368
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
369
|
+
end
|
370
|
+
|
371
|
+
it "finds submit buttons matching the given xpath" do
|
372
|
+
e = @browser.element_by_xpath("//input[@type='submit']")
|
373
|
+
e.should exist
|
374
|
+
end
|
375
|
+
|
376
|
+
it "finds reset buttons matching the given xpath" do
|
377
|
+
e = @browser.element_by_xpath("//input[@type='reset']")
|
378
|
+
e.should exist
|
379
|
+
end
|
380
|
+
|
381
|
+
it "finds image buttons matching the given xpath" do
|
382
|
+
e = @browser.element_by_xpath("//input[@type='image']")
|
383
|
+
e.should exist
|
384
|
+
end
|
385
|
+
|
386
|
+
it "finds the element matching the given xpath" do
|
387
|
+
e = @browser.element_by_xpath("//input[@type='password']")
|
388
|
+
e.should exist
|
389
|
+
end
|
390
|
+
|
391
|
+
it "will not find elements that doesn't exist" do
|
392
|
+
e = @browser.element_by_xpath("//input[@type='foobar']")
|
393
|
+
e.should_not exist
|
394
|
+
lambda { e.set('foo') }.should raise_error(UnknownObjectException)
|
395
|
+
end
|
396
|
+
|
397
|
+
it "returns usable elements even though they're not supported" do
|
398
|
+
el = @browser.element_by_xpath("//link")
|
399
|
+
el.should be_instance_of(Celerity::Element)
|
400
|
+
el.rel.should == "stylesheet"
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
describe "#elements_by_xpath" do
|
405
|
+
before :each do
|
406
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
407
|
+
end
|
408
|
+
|
409
|
+
it "returns an Array of matching elements" do
|
410
|
+
objects = @browser.elements_by_xpath("//*[@type='text']")
|
411
|
+
objects.size.should == 6
|
412
|
+
end
|
413
|
+
|
414
|
+
it "returns an empty Array if there are no matching elements" do
|
415
|
+
objects = @browser.elements_by_xpath("//*[@type='foobar']")
|
416
|
+
objects.size.should == 0
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
describe "#add_checker" do
|
421
|
+
it "raises ArgumentError when not given any arguments" do
|
422
|
+
lambda { @browser.add_checker }.should raise_error(ArgumentError)
|
423
|
+
end
|
424
|
+
|
425
|
+
it "runs the given proc on each page load" do
|
426
|
+
output = ''
|
427
|
+
proc = Proc.new { |ie| output << ie.text }
|
428
|
+
@browser.add_checker(proc)
|
429
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
430
|
+
output.should include('Dubito, ergo cogito, ergo sum')
|
431
|
+
end
|
432
|
+
|
433
|
+
it "runs the given block on each page load" do
|
434
|
+
output = ''
|
435
|
+
@browser.add_checker { |ie| output << ie.text }
|
436
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
437
|
+
output.should include('Dubito, ergo cogito, ergo sum')
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
describe "#disable_checker" do
|
442
|
+
it "removes a previously added checker" do
|
443
|
+
output = ''
|
444
|
+
checker = lambda { |ie| output << ie.text }
|
445
|
+
|
446
|
+
@browser.add_checker(checker)
|
447
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
448
|
+
output.should include('Dubito, ergo cogito, ergo sum')
|
449
|
+
|
450
|
+
@browser.disable_checker(checker)
|
451
|
+
@browser.goto(HTML_DIR + "/definition_lists.html")
|
452
|
+
output.should_not include('definition_lists')
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
describe "#focused_element" do
|
457
|
+
it "returns the element that currently has the focus" do
|
458
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
459
|
+
@browser.focused_element.id.should == "new_user_first_name"
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
describe "#status_code" do
|
464
|
+
it "returns the status code of the last request" do
|
465
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
466
|
+
@browser.status_code.should == 200
|
467
|
+
|
468
|
+
@browser.goto(TEST_HOST + "/doesnt_exist")
|
469
|
+
@browser.status_code.should == 404
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
describe "#status_code_exceptions" do
|
474
|
+
it "raises status code exceptions if set to true" do
|
475
|
+
@browser.status_code_exceptions = true
|
476
|
+
lambda do
|
477
|
+
@browser.goto(TEST_HOST + "/doesnt_exist")
|
478
|
+
end.should raise_error(NavigationException)
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
describe "#javascript_exceptions" do
|
483
|
+
it "raises javascript exceptions if set to true" do
|
484
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
485
|
+
@browser.javascript_exceptions = true
|
486
|
+
lambda do
|
487
|
+
@browser.execute_script("no_such_function()")
|
488
|
+
end.should raise_error
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
describe "#add_listener" do
|
493
|
+
it "should click OK for confirm() calls" do
|
494
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
495
|
+
@browser.add_listener(:confirm) { }
|
496
|
+
@browser.execute_script("confirm()").should == true
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
describe "#remove_listener" do
|
501
|
+
it "should remove the listener" do
|
502
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
503
|
+
@browser.add_listener(:confirm) { }
|
504
|
+
@browser.remove_listener(:confirm) { }
|
505
|
+
@browser.execute_script("confirm()").should != true
|
506
|
+
end
|
507
|
+
end
|
508
|
+
|
509
|
+
describe "#confirm" do
|
510
|
+
it "clicks 'OK' for a confirm() call" do
|
511
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
512
|
+
|
513
|
+
@browser.confirm(true) do
|
514
|
+
@browser.execute_script('confirm()').should be_true
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
518
|
+
it "clicks 'cancel' for a confirm() call" do
|
519
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
520
|
+
|
521
|
+
@browser.confirm(false) do
|
522
|
+
@browser.execute_script('confirm()').should be_false
|
523
|
+
end
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
it "raises UnknownObjectException when trying to access DOM elements on plain/text-page" do
|
528
|
+
@browser.goto(TEST_HOST + "/plain_text")
|
529
|
+
lambda { @browser.div(:id, 'foo').id }.should raise_error(UnknownObjectException)
|
530
|
+
end
|
531
|
+
|
532
|
+
|
533
|
+
after :all do
|
534
|
+
@browser.close
|
535
|
+
end
|
536
|
+
|
537
|
+
end
|