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
data/spec/divs_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Divs" do
|
4
|
+
before :all do
|
5
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
6
|
+
end
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#length" do
|
13
|
+
it "returns the number of divs" do
|
14
|
+
@browser.divs.length.should == 9
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#[]" do
|
19
|
+
it "returns the div at the given index" do
|
20
|
+
@browser.divs[2].id.should == "outer_container"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#each" do
|
25
|
+
it "iterates through divs correctly" do
|
26
|
+
@browser.divs.each_with_index do |d, index|
|
27
|
+
d.name.should == @browser.div(:index, index+1).name
|
28
|
+
d.id.should == @browser.div(:index, index+1).id
|
29
|
+
d.class_name.should == @browser.div(:index, index+1).class_name
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
after :all do
|
35
|
+
@browser.close
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
data/spec/dl_spec.rb
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Dl" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/definition_lists.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# Exists method
|
15
|
+
describe "#exists?" do
|
16
|
+
it "returns true if the element exists" do
|
17
|
+
@browser.dl(:id, "experience-list").should exist
|
18
|
+
@browser.dl(:class, "list").should exist
|
19
|
+
@browser.dl(:xpath, "//dl[@id='experience-list']").should exist
|
20
|
+
@browser.dl(:index, 1).should exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns false if the element does not exist" do
|
24
|
+
@browser.dl(:id, "no_such_id").should_not exist
|
25
|
+
end
|
26
|
+
|
27
|
+
it "raises TypeError when 'what' argument is invalid" do
|
28
|
+
lambda { @browser.dl(:id, 3.14).exists? }.should raise_error(TypeError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
32
|
+
lambda { @browser.dl(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute methods
|
37
|
+
describe "#class_name" do
|
38
|
+
it "returns the class attribute if the element exists" do
|
39
|
+
@browser.dl(:id , "experience-list").class_name.should == "list"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
43
|
+
@browser.dl(:id , "noop").class_name.should == ""
|
44
|
+
end
|
45
|
+
|
46
|
+
it "raises UnknownObjectException if the element does not exist" do
|
47
|
+
lambda { @browser.dl(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
48
|
+
lambda { @browser.dl(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
49
|
+
lambda { @browser.dl(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
50
|
+
lambda { @browser.dl(:xpath, "//dl[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#id" do
|
55
|
+
it "returns the id attribute if the element exists" do
|
56
|
+
@browser.dl(:class, 'list').id.should == "experience-list"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns an empty string if the element exists, but the attribute doesn't" do
|
60
|
+
@browser.dl(:class, 'personalia').id.should == ""
|
61
|
+
end
|
62
|
+
|
63
|
+
it "raises UnknownObjectException if the element does not exist" do
|
64
|
+
lambda {@browser.dl(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
65
|
+
lambda {@browser.dl(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
66
|
+
lambda {@browser.dl(:index, 1337).id }.should raise_error(UnknownObjectException)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#title" do
|
71
|
+
it "returns the id attribute if the element exists" do
|
72
|
+
@browser.dl(:class, 'list').title.should == "experience"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#text" do
|
77
|
+
it "returns the text of the element" do
|
78
|
+
@browser.dl(:id, "experience-list").text.should include("11 years")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns an empty string if the element exists but contains no text" do
|
82
|
+
@browser.dl(:id, 'noop').text.should == ""
|
83
|
+
end
|
84
|
+
|
85
|
+
it "raises UnknownObjectException if the element does not exist" do
|
86
|
+
lambda { @browser.dl(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
87
|
+
lambda { @browser.dl(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
88
|
+
lambda { @browser.dl(:index, 1337).text }.should raise_error(UnknownObjectException)
|
89
|
+
lambda { @browser.dl(:xpath, "//dl[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#respond_to?" do
|
94
|
+
it "returns true for all attribute methods" do
|
95
|
+
@browser.dl(:index, 1).should respond_to(:id)
|
96
|
+
@browser.dl(:index, 1).should respond_to(:class_name)
|
97
|
+
@browser.dl(:index, 1).should respond_to(:style)
|
98
|
+
@browser.dl(:index, 1).should respond_to(:text)
|
99
|
+
@browser.dl(:index, 1).should respond_to(:title)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Manipulation methods
|
104
|
+
describe "#click" do
|
105
|
+
it "fires events when clicked" do
|
106
|
+
@browser.dl(:id, 'noop').text.should_not == 'noop'
|
107
|
+
@browser.dl(:id, 'noop').click
|
108
|
+
@browser.dl(:id, 'noop').text.should == 'noop'
|
109
|
+
end
|
110
|
+
|
111
|
+
it "raises UnknownObjectException if the element does not exist" do
|
112
|
+
lambda { @browser.dl(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
113
|
+
lambda { @browser.dl(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
114
|
+
lambda { @browser.dl(:index, 1337).click }.should raise_error(UnknownObjectException)
|
115
|
+
lambda { @browser.dl(:xpath, "//dl[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#html" do
|
120
|
+
it "returns the HTML of the element" do
|
121
|
+
html = @browser.dl(:id, 'experience-list').html
|
122
|
+
html.should include('<dt class="current-industry">')
|
123
|
+
html.should_not include('</body>')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#to_s" do
|
128
|
+
it "returns a human readable representation of the element" do
|
129
|
+
@browser.dl(:id, 'experience-list').to_s.should ==
|
130
|
+
%q{tag: dl
|
131
|
+
id: experience-list
|
132
|
+
class: list
|
133
|
+
title: experience
|
134
|
+
text: Experience 11 years Education Master Current industry Architecture Previous industry experience Architecture}
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
after :all do
|
139
|
+
@browser.close
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
data/spec/dls_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Dls" do
|
4
|
+
before :all do
|
5
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
6
|
+
end
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@browser.goto(HTML_DIR + "/definition_lists.html")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#length" do
|
13
|
+
it "returns the number of dls" do
|
14
|
+
@browser.dls.length.should == 3
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#[]" do
|
19
|
+
it "returns the dl at the given index" do
|
20
|
+
@browser.dls[1].id.should == "experience-list"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#each" do
|
25
|
+
it "iterates through dls correctly" do
|
26
|
+
@browser.dls.each_with_index do |d, index|
|
27
|
+
d.text.should == @browser.dl(:index, index+1).text
|
28
|
+
d.id.should == @browser.dl(:index, index+1).id
|
29
|
+
d.class_name.should == @browser.dl(:index, index+1).class_name
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
after :all do
|
35
|
+
@browser.close
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
data/spec/dt_spec.rb
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Dt" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/definition_lists.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# Exists method
|
15
|
+
describe "#exists?" do
|
16
|
+
it "returns true if the element exists" do
|
17
|
+
@browser.dt(:id, "experience").should exist
|
18
|
+
@browser.dt(:class, "current-industry").should exist
|
19
|
+
@browser.dt(:xpath, "//dt[@id='experience']").should exist
|
20
|
+
@browser.dt(:index, 1).should exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns false if the element does not exist" do
|
24
|
+
@browser.dt(:id, "no_such_id").should_not exist
|
25
|
+
end
|
26
|
+
|
27
|
+
it "raises TypeError when 'what' argument is invalid" do
|
28
|
+
lambda { @browser.dt(:id, 3.14).exists? }.should raise_error(TypeError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
32
|
+
lambda { @browser.dt(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute methods
|
37
|
+
describe "#class_name" do
|
38
|
+
it "returns the class attribute if the element exists" do
|
39
|
+
@browser.dt(:id , "experience").class_name.should == "industry"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
43
|
+
@browser.dt(:id , "education").class_name.should == ""
|
44
|
+
end
|
45
|
+
|
46
|
+
it "raises UnknownObjectException if the element does not exist" do
|
47
|
+
lambda { @browser.dt(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
48
|
+
lambda { @browser.dt(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
49
|
+
lambda { @browser.dt(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
50
|
+
lambda { @browser.dt(:xpath, "//dt[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#id" do
|
55
|
+
it "returns the id attribute if the element exists" do
|
56
|
+
@browser.dt(:class, 'industry').id.should == "experience"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns an empty string if the element exists, but the attribute doesn't" do
|
60
|
+
@browser.dt(:class, 'current-industry').id.should == ""
|
61
|
+
end
|
62
|
+
|
63
|
+
it "raises UnknownObjectException if the element does not exist" do
|
64
|
+
lambda {@browser.dt(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
65
|
+
lambda {@browser.dt(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
66
|
+
lambda {@browser.dt(:index, 1337).id }.should raise_error(UnknownObjectException)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#title" do
|
71
|
+
it "returns the title of the element" do
|
72
|
+
@browser.dt(:id, "experience").title.should == "experience"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#text" do
|
77
|
+
it "returns the text of the element" do
|
78
|
+
@browser.dt(:id, "experience").text.should == "Experience"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns an empty string if the element exists but contains no text" do
|
82
|
+
@browser.dt(:class, 'noop').text.should == ""
|
83
|
+
end
|
84
|
+
|
85
|
+
it "raises UnknownObjectException if the element does not exist" do
|
86
|
+
lambda { @browser.dt(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
87
|
+
lambda { @browser.dt(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
88
|
+
lambda { @browser.dt(:index, 1337).text }.should raise_error(UnknownObjectException)
|
89
|
+
lambda { @browser.dt(:xpath, "//dt[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#respond_to?" do
|
94
|
+
it "returns true for all attribute methods" do
|
95
|
+
@browser.dt(:index, 1).should respond_to(:id)
|
96
|
+
@browser.dt(:index, 1).should respond_to(:class_name)
|
97
|
+
@browser.dt(:index, 1).should respond_to(:style)
|
98
|
+
@browser.dt(:index, 1).should respond_to(:text)
|
99
|
+
@browser.dt(:index, 1).should respond_to(:title)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Manipulation methods
|
104
|
+
describe "#click" do
|
105
|
+
it "fires events when clicked" do
|
106
|
+
@browser.dt(:id, 'education').text.should_not == 'changed'
|
107
|
+
@browser.dt(:id, 'education').click
|
108
|
+
@browser.dt(:id, 'education').text.should == 'changed'
|
109
|
+
end
|
110
|
+
|
111
|
+
it "raises UnknownObjectException if the element does not exist" do
|
112
|
+
lambda { @browser.dt(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
113
|
+
lambda { @browser.dt(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
114
|
+
lambda { @browser.dt(:index, 1337).click }.should raise_error(UnknownObjectException)
|
115
|
+
lambda { @browser.dt(:xpath, "//dt[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#html" do
|
120
|
+
it "returns the HTML of the element" do
|
121
|
+
html = @browser.dt(:id, 'name').html
|
122
|
+
html.should match(%r"<div>.*Name.*</div>"m)
|
123
|
+
html.should_not include('</body>')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#to_s" do
|
128
|
+
it "returns a human readable representation of the element" do
|
129
|
+
@browser.dt(:id, 'experience').to_s.should ==
|
130
|
+
%q{tag: dt
|
131
|
+
id: experience
|
132
|
+
class: industry
|
133
|
+
title: experience
|
134
|
+
text: Experience}
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
after :all do
|
139
|
+
@browser.close
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
data/spec/dts_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Dts" do
|
4
|
+
before :all do
|
5
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
6
|
+
end
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@browser.goto(HTML_DIR + "/definition_lists.html")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#length" do
|
13
|
+
it "returns the number of dts" do
|
14
|
+
@browser.dts.length.should == 11
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#[]" do
|
19
|
+
it "returns the dt at the given index" do
|
20
|
+
@browser.dts[1].id.should == "experience"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#each" do
|
25
|
+
it "iterates through dts correctly" do
|
26
|
+
@browser.dts.each_with_index do |d, index|
|
27
|
+
d.name.should == @browser.dt(:index, index+1).name
|
28
|
+
d.id.should == @browser.dt(:index, index+1).id
|
29
|
+
d.class_name.should == @browser.dt(:index, index+1).class_name
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
after :all do
|
35
|
+
@browser.close
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Element" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".new" do
|
14
|
+
it "finds elements matching the conditions when given a hash of :how => 'what' arguments" do
|
15
|
+
@browser.checkbox(:name => 'new_user_interests', :title => 'Dancing is fun!').value.should == 'dancing'
|
16
|
+
@browser.text_field(:class_name => 'name', :index => 2).id.should == 'new_user_last_name'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "raises UnknownObjectException with a sane error message when given a hash of :how => 'what' arguments (non-existing object)" do
|
20
|
+
conditions = {:index => 100, :name => "foo"}
|
21
|
+
lambda { @browser.text_field(conditions).id }.should raise_error(UnknownObjectException, /Unable to locate TextField, using (\{:name=>"foo", :index=>100\}|\{:index=>100, :name=>"foo"\})/)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "raises ArgumentError if given the wrong number of arguments" do
|
25
|
+
container = mock("container", :null_object => true)
|
26
|
+
lambda { Element.new(container, 1,2,3,4) }.should raise_error(ArgumentError, "wrong number of arguments (4 for 2)")
|
27
|
+
lambda { Element.new(container, "foo") }.should raise_error(ArgumentError, "wrong number of arguments (1 for 2)")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#locate" do
|
32
|
+
it "raises ArgumentError when used with :object and the object given isn't an HtmlElement subclass" do
|
33
|
+
lambda { Link.new(@browser, :object, "foo").locate }.should raise_error(ArgumentError)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#focus" do
|
39
|
+
it "fires the onfocus event for the given element" do
|
40
|
+
tf = @browser.text_field(:id, "new_user_occupation")
|
41
|
+
tf.value.should == "Developer"
|
42
|
+
tf.focus
|
43
|
+
@browser.div(:id, "onfocus_test").text.should == "changed by onfocus event"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#fire_event" do
|
48
|
+
it "should fire the given event" do
|
49
|
+
@browser.div(:id, "onfocus_test").text.should be_empty
|
50
|
+
@browser.text_field(:id, "new_user_occupation").fire_event('onfocus')
|
51
|
+
@browser.div(:id, "onfocus_test").text.should == "changed by onfocus event"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#javascript_object" do
|
56
|
+
it "should return the JavaScript object representing the receiver" do
|
57
|
+
obj = @browser.div(:id, "onfocus_test").javascript_object
|
58
|
+
obj.should be_kind_of(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement)
|
59
|
+
obj.should be_instance_of(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDivElement)
|
60
|
+
obj.client_width.should be_kind_of(Integer)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#parent" do
|
65
|
+
it "gets the parent of this element" do
|
66
|
+
@browser.text_field(:id, "new_user_email").parent.should be_instance_of(Form)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#xpath" do
|
71
|
+
it "gets the canonical xpath of this element" do
|
72
|
+
@browser.text_field(:id, "new_user_email").xpath.should == '/html/body/form[1]/fieldset[1]/input[3]'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#visible?" do
|
77
|
+
it "returns true if the element is visible" do
|
78
|
+
@browser.text_field(:id, "new_user_email").should be_visible
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns false if the element is input element where type == 'hidden'" do
|
82
|
+
@browser.text_field(:id, "new_user_interests_dolls").should_not be_visible
|
83
|
+
end
|
84
|
+
|
85
|
+
it "returns false if the element has style='display: none;'" do
|
86
|
+
@browser.div(:id, 'changed_language').should_not be_visible
|
87
|
+
end
|
88
|
+
|
89
|
+
it "returns false if the element has style='visibility: hidden;" do
|
90
|
+
@browser.div(:id, 'wants_newsletter').should_not be_visible
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns false if one of the parent elements is hidden" do
|
94
|
+
@browser.div(:id, 'hidden_parent').should_not be_visible
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "#exist?" do
|
99
|
+
it "doesn't raise when called on nested elements" do
|
100
|
+
@browser.div(:id, 'no_such_div').link(:id, 'no_such_id').should_not exist
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#identifier_string" do
|
105
|
+
it "doesn't make the next locate find the wrong element" do
|
106
|
+
elem = @browser.div(:id, 'hidden_parent')
|
107
|
+
elem.should exist
|
108
|
+
def elem.public_identifier_string; identifier_string end # method is private
|
109
|
+
elem.public_identifier_string
|
110
|
+
elem.id.should == 'hidden_parent'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#method_missing" do
|
115
|
+
it "magically returns the requested attribute if the attribute is defined in the attribute list" do
|
116
|
+
@browser.form(:index, 1).action.should == 'post_to_me'
|
117
|
+
end
|
118
|
+
|
119
|
+
it "raises NoMethodError if the requested method isn't among the attributes" do
|
120
|
+
lambda { @browser.button(:index, 1).no_such_attribute_or_method }.should raise_error(NoMethodError)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
# disabled for CI - need fix from HtmlUnit
|
126
|
+
|
127
|
+
# describe "#html" do
|
128
|
+
# it "returns the descriptive (actual) html for the image element" do
|
129
|
+
# @browser.goto(HTML_DIR + "/images.html")
|
130
|
+
# @browser.image(:id, 'non_self_closing').html.chomp.should == '<img src="images/1.gif" alt="1" id="non_self_closing"></img>'
|
131
|
+
# @browser.goto(HTML_DIR + "/non_control_elements.html")
|
132
|
+
# @browser.div(:id, 'html_test').html.chomp.should ==
|
133
|
+
# '<div id="html_test" class=some_class title = "This is a title">
|
134
|
+
# asdf
|
135
|
+
# </div>' #TODO: This expected value might be a little off, whitespace-wise
|
136
|
+
# end
|
137
|
+
# end
|
138
|
+
|
139
|
+
# disabled for CI - need fix from HtmlUnit
|
140
|
+
# describe "#text" do
|
141
|
+
# it "returns a text representation including newlines" do
|
142
|
+
# @browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
143
|
+
# @browser.form(:id, "delete_user").text.should == "Username Username 1 Username 2 Username 3 \nComment Default comment."
|
144
|
+
# end
|
145
|
+
# end
|
146
|
+
|
147
|
+
after :all do
|
148
|
+
@browser.close
|
149
|
+
end
|
150
|
+
end
|