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/em_spec.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Em" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/non_control_elements.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
# Exists method
|
14
|
+
describe "#exists?" do
|
15
|
+
it "returns true if the element exists" do
|
16
|
+
@browser.em(:id, "important-id").should exist
|
17
|
+
@browser.em(:class, "important-class").should exist
|
18
|
+
@browser.em(:xpath, "//em[@id='important-id']").should exist
|
19
|
+
@browser.em(:index, 1).should exist
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns false if the element does not exist" do
|
23
|
+
@browser.em(:id, "no_such_id").should_not exist
|
24
|
+
end
|
25
|
+
|
26
|
+
it "raises TypeError when 'what' argument is invalid" do
|
27
|
+
lambda { @browser.em(:id, 3.14).exists? }.should raise_error(TypeError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
31
|
+
lambda { @browser.em(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute methods
|
36
|
+
describe "#class_name" do
|
37
|
+
it "returns the class attribute if the element exists" do
|
38
|
+
@browser.em(:id, "important-id").class_name.should == "important-class"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises UnknownObjectException if the element does not exist" do
|
42
|
+
lambda { @browser.em(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
43
|
+
lambda { @browser.em(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
44
|
+
lambda { @browser.em(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
45
|
+
lambda { @browser.em(:xpath, "//em[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#id" do
|
50
|
+
it "returns the id attribute if the element exists" do
|
51
|
+
@browser.em(:class, 'important-class').id.should == "important-id"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "raises UnknownObjectException if the element does not exist" do
|
55
|
+
lambda {@browser.em(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
56
|
+
lambda {@browser.em(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
57
|
+
lambda {@browser.em(:index, 1337).id }.should raise_error(UnknownObjectException)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#title" do
|
62
|
+
it "returns the title of the element" do
|
63
|
+
@browser.em(:class, "important-class").title.should == "ergo cogito"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#text" do
|
68
|
+
it "returns the text of the element" do
|
69
|
+
@browser.em(:id, "important-id").text.should == "ergo cogito"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "raises UnknownObjectException if the element does not exist" do
|
73
|
+
lambda { @browser.em(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
74
|
+
lambda { @browser.em(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
75
|
+
lambda { @browser.em(:index, 1337).text }.should raise_error(UnknownObjectException)
|
76
|
+
lambda { @browser.em(:xpath, "//em[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#respond_to?" do
|
81
|
+
it "returns true for all attribute methods" do
|
82
|
+
@browser.em(:index, 1).should respond_to(:id)
|
83
|
+
@browser.em(:index, 1).should respond_to(:class_name)
|
84
|
+
@browser.em(:index, 1).should respond_to(:style)
|
85
|
+
@browser.em(:index, 1).should respond_to(:text)
|
86
|
+
@browser.em(:index, 1).should respond_to(:title)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Manipulation methods
|
91
|
+
describe "#click" do
|
92
|
+
it "raises UnknownObjectException if the element does not exist" do
|
93
|
+
lambda { @browser.em(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
94
|
+
lambda { @browser.em(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
95
|
+
lambda { @browser.em(:index, 1337).click }.should raise_error(UnknownObjectException)
|
96
|
+
lambda { @browser.em(:xpath, "//em[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#to_s" do
|
101
|
+
it "returns a human readable representation of the element" do
|
102
|
+
@browser.em(:id, 'important-id').to_s.should ==
|
103
|
+
%q{tag: em
|
104
|
+
class: important-class
|
105
|
+
id: important-id
|
106
|
+
title: ergo cogito
|
107
|
+
text: ergo cogito}
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
after :all do
|
112
|
+
@browser.close
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
data/spec/ems_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Ems" 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 ems" do
|
14
|
+
@browser.ems.length.should == 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#[]" do
|
19
|
+
it "returns the em at the given index" do
|
20
|
+
@browser.ems[1].id.should == "important-id"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#each" do
|
25
|
+
it "iterates through ems correctly" do
|
26
|
+
@browser.ems.each_with_index do |e, index|
|
27
|
+
e.text.should == @browser.em(:index, index+1).text
|
28
|
+
e.id.should == @browser.em(:index, index+1).id
|
29
|
+
e.class_name.should == @browser.em(: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,133 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "FileField" do
|
4
|
+
before :all do
|
5
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
6
|
+
end
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#exist?" do
|
13
|
+
it "returns true if the file field exists" do
|
14
|
+
@browser.file_field(:id, 'new_user_portrait').should exist
|
15
|
+
@browser.file_field(:id, /new_user_portrait/).should exist
|
16
|
+
@browser.file_field(:name, 'new_user_portrait').should exist
|
17
|
+
@browser.file_field(:name, /new_user_portrait/).should exist
|
18
|
+
@browser.file_field(:class, 'portrait').should exist
|
19
|
+
@browser.file_field(:class, /portrait/).should exist
|
20
|
+
@browser.file_field(:index, 1).should exist
|
21
|
+
@browser.file_field(:xpath, "//input[@id='new_user_portrait']").should exist
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns true if the element exists (default how = :name)" do
|
25
|
+
@browser.file_field("new_user_portrait").should exist
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns false if the file field doesn't exist" do
|
29
|
+
@browser.file_field(:id, 'no_such_id').should_not exist
|
30
|
+
@browser.file_field(:id, /no_such_id/).should_not exist
|
31
|
+
@browser.file_field(:name, 'no_such_name').should_not exist
|
32
|
+
@browser.file_field(:name, /no_such_name/).should_not exist
|
33
|
+
@browser.file_field(:class, 'no_such_class').should_not exist
|
34
|
+
@browser.file_field(:class, /no_such_class/).should_not exist
|
35
|
+
@browser.file_field(:index, 1337).should_not exist
|
36
|
+
@browser.file_field(:xpath, "//input[@id='no_such_id']").should_not exist
|
37
|
+
end
|
38
|
+
|
39
|
+
it "raises TypeError when 'what' argument is invalid" do
|
40
|
+
lambda { @browser.file_field(:id, 3.14).exists? }.should raise_error(TypeError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
44
|
+
lambda { @browser.file_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Attribute methods
|
49
|
+
|
50
|
+
describe "#class_name" do
|
51
|
+
it "returns the class attribute if the text field exists" do
|
52
|
+
@browser.file_field(:index, 1).class_name.should == "portrait"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
56
|
+
lambda { @browser.file_field(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#id" do
|
61
|
+
it "returns the id attribute if the text field exists" do
|
62
|
+
@browser.file_field(:index, 1).id.should == "new_user_portrait"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
66
|
+
lambda { @browser.file_field(:index, 1337).id }.should raise_error(UnknownObjectException)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#name" do
|
71
|
+
it "returns the name attribute if the text field exists" do
|
72
|
+
@browser.file_field(:index, 1).name.should == "new_user_portrait"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
76
|
+
lambda { @browser.file_field(:index, 1337).name }.should raise_error(UnknownObjectException)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#title" do
|
81
|
+
it "returns the title attribute if the text field exists" do
|
82
|
+
@browser.file_field(:id, "new_user_portrait").title.should == "Smile!"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#type" do
|
87
|
+
it "returns the type attribute if the text field exists" do
|
88
|
+
@browser.file_field(:index, 1).type.should == "file"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
92
|
+
lambda { @browser.file_field(:index, 1337).type }.should raise_error(UnknownObjectException)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#respond_to?" do
|
97
|
+
it "returns true for all attribute methods" do
|
98
|
+
@browser.file_field(:index, 1).should respond_to(:class_name)
|
99
|
+
@browser.file_field(:index, 1).should respond_to(:id)
|
100
|
+
@browser.file_field(:index, 1).should respond_to(:name)
|
101
|
+
@browser.file_field(:index, 1).should respond_to(:title)
|
102
|
+
@browser.file_field(:index, 1).should respond_to(:type)
|
103
|
+
@browser.file_field(:index, 1).should respond_to(:value)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Manipulation methods
|
108
|
+
|
109
|
+
describe "#set" do
|
110
|
+
it "is able to set a file path in the field and click the upload button and fire the onchange event" do
|
111
|
+
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
112
|
+
|
113
|
+
alerts = []
|
114
|
+
@browser.add_listener(:alert) { |_, msg| alerts << msg }
|
115
|
+
@browser.file_field(:name, "new_user_portrait").set(__FILE__)
|
116
|
+
@browser.file_field(:name, "new_user_portrait").value.should == __FILE__
|
117
|
+
alerts.should == [__FILE__]
|
118
|
+
@browser.button(:name, "new_user_submit").click
|
119
|
+
end
|
120
|
+
|
121
|
+
it "sends content as correct content type for common file types" do
|
122
|
+
@browser.file_field(:name, "new_user_portrait").set("foo.doc")
|
123
|
+
obj = @browser.file_field(:name, "new_user_portrait").locate
|
124
|
+
obj.getContentType.should == "application/msword"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
after :all do
|
129
|
+
@browser.close
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "FileFields" 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 "#length" do
|
14
|
+
it "returns the correct number of file fields" do
|
15
|
+
@browser.file_fields.length.should == 2
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#[]" do
|
20
|
+
it "returns the file field at the given index" do
|
21
|
+
@browser.file_fields[1].id.should == "new_user_portrait"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#each" do
|
26
|
+
it "iterates through file fields correctly" do
|
27
|
+
@browser.file_fields.each_with_index do |f, index|
|
28
|
+
f.name.should == @browser.file_field(:index, index+1).name
|
29
|
+
f.id.should == @browser.file_field(:index, index+1).id
|
30
|
+
f.value.should == @browser.file_field(:index, index+1).value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
after :all do
|
36
|
+
@browser.close
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
data/spec/form_spec.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Form" do
|
4
|
+
before :all do
|
5
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
6
|
+
end
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@browser.goto(HTML_DIR + "/forms_with_input_elements.html")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#exists" do
|
13
|
+
it "returns true if the form exists" do
|
14
|
+
@browser.form(:id, 'new_user').should exist
|
15
|
+
@browser.form(:id, /new_user/).should exist
|
16
|
+
@browser.form(:class, 'user').should exist
|
17
|
+
@browser.form(:class, /user/).should exist
|
18
|
+
@browser.form(:method, 'post').should exist
|
19
|
+
@browser.form(:method, /post/).should exist
|
20
|
+
@browser.form(:action, 'post_to_me').should exist
|
21
|
+
@browser.form(:action, /to_me/).should exist
|
22
|
+
@browser.form(:index, 1).should exist
|
23
|
+
@browser.form(:xpath, "//form[@id='new_user']").should exist
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns true if the element exists (default how = :name)" do
|
27
|
+
@browser.form("user_new").should exist
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns false if the form doesn't exist" do
|
31
|
+
@browser.form(:id, 'no_such_id').should_not exist
|
32
|
+
@browser.form(:id, /no_such_id/).should_not exist
|
33
|
+
@browser.form(:class, 'no_such_class').should_not exist
|
34
|
+
@browser.form(:class, /no_such_class/).should_not exist
|
35
|
+
@browser.form(:method, 'no_such_method').should_not exist
|
36
|
+
@browser.form(:method, /no_such_method/).should_not exist
|
37
|
+
@browser.form(:action, 'no_such_action').should_not exist
|
38
|
+
@browser.form(:action, /no_such_action/).should_not exist
|
39
|
+
@browser.form(:index, 1337).should_not exist
|
40
|
+
@browser.form(:xpath, "//form[@id='no_such_id']").should_not exist
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises TypeError when 'what' argument is invalid" do
|
44
|
+
lambda { @browser.form(:id, 3.14).exists? }.should raise_error(TypeError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
48
|
+
lambda { @browser.form(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#submit" do
|
53
|
+
it "submits the form" do
|
54
|
+
@browser.form(:id, "delete_user").submit
|
55
|
+
@browser.text.should include("Semantic table")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/spec/forms_spec.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Forms" 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 "#length" do
|
14
|
+
it "returns the number of forms in the container" do
|
15
|
+
@browser.forms.length.should == 2
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#[]n" do
|
20
|
+
it "provides access to the nth form" do
|
21
|
+
@browser.forms[1].action.should == 'post_to_me'
|
22
|
+
@browser.forms[1].attribute_value('method').should == 'post'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#each" do
|
27
|
+
it "iterates through forms correctly" do
|
28
|
+
@browser.forms.each_with_index do |f, index|
|
29
|
+
f.name.should == @browser.form(:index, index+1).name
|
30
|
+
f.id.should == @browser.form(:index, index+1).id
|
31
|
+
f.class_name.should == @browser.form(:index, index+1).class_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
after :all do
|
37
|
+
@browser.close
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
data/spec/frame_spec.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Frame" do
|
4
|
+
before :all do
|
5
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
6
|
+
end
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@browser.goto(HTML_DIR + "/frames.html")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "handles crossframe javascript" do
|
13
|
+
@browser.frame(:id, "frame_1").text_field(:name, 'senderElement').value.should == 'send_this_value'
|
14
|
+
@browser.frame(:id, "frame_2").text_field(:name, 'recieverElement').value.should == 'old_value'
|
15
|
+
@browser.frame(:id, "frame_1").button(:id, 'send').click
|
16
|
+
@browser.frame(:id, "frame_2").text_field(:name, 'recieverElement').value.should == 'send_this_value'
|
17
|
+
end
|
18
|
+
|
19
|
+
# Exists
|
20
|
+
describe "#exist?" do
|
21
|
+
it "returns true if the frame exists" do
|
22
|
+
@browser.frame(:id, "frame_1").should exist
|
23
|
+
@browser.frame(:id, /frame/).should exist
|
24
|
+
@browser.frame(:name, "frame1").should exist
|
25
|
+
@browser.frame(:name, /frame/).should exist
|
26
|
+
@browser.frame(:src, "frame_1.html").should exist
|
27
|
+
@browser.frame(:src, /frame_1/).should exist
|
28
|
+
@browser.frame(:class, "half").should exist
|
29
|
+
@browser.frame(:class, /half/).should exist
|
30
|
+
@browser.frame(:index, 1).should exist
|
31
|
+
@browser.frame(:xpath, "//frame[@id='frame_1']").should exist
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns true if the iframe exists" do
|
35
|
+
@browser.goto(HTML_DIR + "/iframes.html")
|
36
|
+
@browser.frame(:id, "frame_1").should exist
|
37
|
+
@browser.frame(:id, /frame/).should exist
|
38
|
+
@browser.frame(:name, "frame1").should exist
|
39
|
+
@browser.frame(:name, /frame/).should exist
|
40
|
+
@browser.frame(:src, "frame_1.html").should exist
|
41
|
+
@browser.frame(:src, /frame_1/).should exist
|
42
|
+
@browser.frame(:class, "iframe").should exist
|
43
|
+
@browser.frame(:class, /iframe/).should exist
|
44
|
+
@browser.frame(:index, 1).should exist
|
45
|
+
@browser.frame(:xpath, "//iframe[@id='frame_1']").should exist
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns true if the element exists (default how = :name)" do
|
49
|
+
@browser.frame("frame1").should exist
|
50
|
+
@browser.goto(HTML_DIR + "/iframes.html")
|
51
|
+
@browser.frame("frame1").should exist
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns false if the frame doesn't exist" do
|
55
|
+
@browser.frame(:id, "no_such_id").should_not exist
|
56
|
+
@browser.frame(:id, /no_such_id/).should_not exist
|
57
|
+
@browser.frame(:name, "no_such_text").should_not exist
|
58
|
+
@browser.frame(:name, /no_such_text/).should_not exist
|
59
|
+
@browser.frame(:src, "no_such_src").should_not exist
|
60
|
+
@browser.frame(:src, /no_such_src/).should_not exist
|
61
|
+
@browser.frame(:class, "no_such_class").should_not exist
|
62
|
+
@browser.frame(:class, /no_such_class/).should_not exist
|
63
|
+
@browser.frame(:index, 1337).should_not exist
|
64
|
+
@browser.frame(:xpath, "//frame[@id='no_such_id']").should_not exist
|
65
|
+
end
|
66
|
+
|
67
|
+
it "raises TypeError when 'what' argument is invalid" do
|
68
|
+
lambda { @browser.frame(:id, 3.14).exists? }.should raise_error(TypeError)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
72
|
+
lambda { @browser.frame(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it "raises UnknownFrameException when accessing elements inside non-existing frame" do
|
77
|
+
lambda { @browser.frame(:name, "no_such_name").p(:index, 1).id }.should raise_error(UnknownFrameException)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "raises UnknownFrameException when accessing a non-existing frame" do
|
81
|
+
lambda { @browser.frame(:name, "no_such_name").id }.should raise_error(UnknownFrameException)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "raises UnknownFrameException when accessing a non-existing subframe" do
|
85
|
+
lambda { @browser.frame(:name, "frame1").frame(:name, "no_such_name").id }.should raise_error(UnknownFrameException)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "raises UnknownObjectException when accessing a non-existing element inside an existing frame" do
|
89
|
+
lambda { @browser.frame(:index, 1).p(:index, 1337).id }.should raise_error(UnknownObjectException)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "raises NoMethodError when trying to access attributes it doesn't have" do
|
93
|
+
lambda { @browser.frame(:index, 1).foo }.should raise_error(NoMethodError)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "is able to send a value to another frame by using Javascript" do
|
97
|
+
frame1, frame2 = @browser.frame(:index, 1), @browser.frame(:index, 2)
|
98
|
+
frame1.text_field(:index, 1).value.should == "send_this_value"
|
99
|
+
frame2.text_field(:index, 1).value.should == "old_value"
|
100
|
+
frame1.button(:index, 1).click
|
101
|
+
frame2.text_field(:index, 1).value.should == "send_this_value"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "is able to set a field" do
|
105
|
+
@browser.frame(:index, 1).text_field(:name, 'senderElement').set("new value")
|
106
|
+
@browser.frame(:index, 1).text_field(:name, 'senderElement').value.should == "new value"
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#contains_text" do
|
110
|
+
it "finds text in a frame" do
|
111
|
+
@browser.frame(:name, 'frame1').contains_text('Suspendisse sit amet nisi.').should be_instance_of(Fixnum)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "raises TypeError when given an invalid argument" do
|
115
|
+
lambda { @browser.frame(:name, 'frame1').contains_text(3.14) }.should raise_error(TypeError)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#execute_script" do
|
120
|
+
it "executes the given javascript in the specified frame" do
|
121
|
+
frame = @browser.frame(:index, 1)
|
122
|
+
frame.div(:id, 'set_by_js').text.should == ""
|
123
|
+
frame.execute_script(%Q{document.getElementById('set_by_js').innerHTML = 'Art consists of limitation. The most beautiful part of every picture is the frame.'})
|
124
|
+
frame.div(:id, 'set_by_js').text.should == "Art consists of limitation. The most beautiful part of every picture is the frame."
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "#to_s" do
|
129
|
+
it "returns a human readable representation of the frame" do
|
130
|
+
@browser.frame(:index, 1).to_s.should == "tag: frame\n" +
|
131
|
+
" src: frame_1.html\n" +
|
132
|
+
" id: frame_1\n" +
|
133
|
+
" name: frame1\n" +
|
134
|
+
" class: half"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|