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/tables_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Tables" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@browser = Browser.new(BROWSER_OPTIONS)
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@browser.goto(HTML_DIR + "/tables.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#length" do
|
14
|
+
it "returns the number of tables" do
|
15
|
+
@browser.tables.length.should == 4
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#[]" do
|
20
|
+
it "returns the p at the given index" do
|
21
|
+
@browser.tables[1].id.should == "axis_example"
|
22
|
+
@browser.tables[2].id.should == "outer"
|
23
|
+
@browser.tables[3].id.should == "inner"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#each" do
|
28
|
+
it "iterates through tables correctly" do
|
29
|
+
@browser.tables.each_with_index do |t, index|
|
30
|
+
t.name.should == @browser.table(:index, index+1).name
|
31
|
+
t.id.should == @browser.table(:index, index+1).id
|
32
|
+
t.value.should == @browser.table(:index, index+1).value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
after :all do
|
38
|
+
@browser.close
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,331 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "TextField" 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
|
+
# Exists method
|
14
|
+
describe "#exists?" do
|
15
|
+
it "returns true if the element exists" do
|
16
|
+
@browser.text_field(:id, 'new_user_email').should exist
|
17
|
+
@browser.text_field(:id, /new_user_email/).should exist
|
18
|
+
@browser.text_field(:name, 'new_user_email').should exist
|
19
|
+
@browser.text_field(:name, /new_user_email/).should exist
|
20
|
+
@browser.text_field(:value, 'Developer').should exist
|
21
|
+
@browser.text_field(:value, /Developer/).should exist
|
22
|
+
@browser.text_field(:text, 'Developer').should exist
|
23
|
+
@browser.text_field(:text, /Developer/).should exist
|
24
|
+
@browser.text_field(:class, 'name').should exist
|
25
|
+
@browser.text_field(:class, /name/).should exist
|
26
|
+
@browser.text_field(:index, 1).should exist
|
27
|
+
@browser.text_field(:xpath, "//input[@id='new_user_email']").should exist
|
28
|
+
@browser.text_field(:label, "First name").should exist
|
29
|
+
@browser.text_field(:label, /(Last|First) name/).should exist
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns true if the element exists (default how = :name)" do
|
33
|
+
@browser.text_field("new_user_email").should exist
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns true if the element exists (no type attribute)" do
|
37
|
+
@browser.text_field(:id, 'new_user_first_name').should exist
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns true if the element exists (invalid type attribute)" do
|
41
|
+
@browser.text_field(:id, 'new_user_last_name').should exist
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns false if the element does not exist" do
|
45
|
+
@browser.text_field(:id, 'no_such_id').should_not exist
|
46
|
+
@browser.text_field(:id, /no_such_id/).should_not exist
|
47
|
+
@browser.text_field(:name, 'no_such_name').should_not exist
|
48
|
+
@browser.text_field(:name, /no_such_name/).should_not exist
|
49
|
+
@browser.text_field(:value, 'no_such_value').should_not exist
|
50
|
+
@browser.text_field(:value, /no_such_value/).should_not exist
|
51
|
+
@browser.text_field(:text, 'no_such_text').should_not exist
|
52
|
+
@browser.text_field(:text, /no_such_text/).should_not exist
|
53
|
+
@browser.text_field(:class, 'no_such_class').should_not exist
|
54
|
+
@browser.text_field(:class, /no_such_class/).should_not exist
|
55
|
+
@browser.text_field(:index, 1337).should_not exist
|
56
|
+
@browser.text_field(:xpath, "//input[@id='no_such_id']").should_not exist
|
57
|
+
@browser.text_field(:label, "bad label").should_not exist
|
58
|
+
@browser.text_field(:label, /bad label/).should_not exist
|
59
|
+
end
|
60
|
+
|
61
|
+
it "raises TypeError when 'what' argument is invalid" do
|
62
|
+
lambda { @browser.text_field(:id, 3.14).exists? }.should raise_error(TypeError)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
66
|
+
lambda { @browser.text_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Attribute methods
|
71
|
+
describe "#id" do
|
72
|
+
it "returns the id attribute if the text field exists" do
|
73
|
+
@browser.text_field(:index, 4).id.should == "new_user_occupation"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
77
|
+
lambda { @browser.text_field(:index, 1337).id }.should raise_error(UnknownObjectException)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#name" do
|
82
|
+
it "returns the name attribute if the text field exists" do
|
83
|
+
@browser.text_field(:index, 4).name.should == "new_user_occupation"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
87
|
+
lambda { @browser.text_field(:index, 1337).name }.should raise_error(UnknownObjectException)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#title" do
|
92
|
+
it "returns the title attribute if the text field exists" do
|
93
|
+
@browser.text_field(:id, "new_user_code").title.should == "Your personal code"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
97
|
+
lambda { @browser.text_field(:index, 1337).title }.should raise_error(UnknownObjectException)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "#type" do
|
102
|
+
it "returns the type attribute if the text field exists" do
|
103
|
+
@browser.text_field(:index, 4).type.should == "text"
|
104
|
+
end
|
105
|
+
|
106
|
+
it "returns 'text' if the type attribute is invalid" do
|
107
|
+
@browser.text_field(:id, 'new_user_last_name').type.should == "text"
|
108
|
+
end
|
109
|
+
|
110
|
+
it "returns 'text' if the type attribute does not exist" do
|
111
|
+
@browser.text_field(:id, 'new_user_first_name').type.should == "text"
|
112
|
+
end
|
113
|
+
|
114
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
115
|
+
lambda { @browser.text_field(:index, 1337).type }.should raise_error(UnknownObjectException)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#value" do
|
120
|
+
it "returns the value attribute if the text field exists" do
|
121
|
+
@browser.text_field(:name, "new_user_occupation").value.should == "Developer"
|
122
|
+
@browser.text_field(:index, 4).value.should == "Developer"
|
123
|
+
@browser.text_field(:name, /new_user_occupation/i).value.should == "Developer"
|
124
|
+
end
|
125
|
+
|
126
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
127
|
+
lambda { @browser.text_field(:index, 1337).value }.should raise_error(UnknownObjectException)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "#respond_to?" do
|
132
|
+
it "returns true for all attribute methods" do
|
133
|
+
@browser.text_field(:index, 1).should respond_to(:class_name)
|
134
|
+
@browser.text_field(:index, 1).should respond_to(:id)
|
135
|
+
@browser.text_field(:index, 1).should respond_to(:name)
|
136
|
+
@browser.text_field(:index, 1).should respond_to(:title)
|
137
|
+
@browser.text_field(:index, 1).should respond_to(:type)
|
138
|
+
@browser.text_field(:index, 1).should respond_to(:value)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
# Access methods
|
144
|
+
describe "#enabled?" do
|
145
|
+
it "returns true for enabled text fields" do
|
146
|
+
@browser.text_field(:name, "new_user_occupation").should be_enabled
|
147
|
+
@browser.text_field(:id, "new_user_email").should be_enabled
|
148
|
+
end
|
149
|
+
|
150
|
+
it "returns false for disabled text fields" do
|
151
|
+
@browser.text_field(:name, "new_user_species").should_not be_enabled
|
152
|
+
end
|
153
|
+
|
154
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
155
|
+
lambda { @browser.text_field(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "#disabled?" do
|
160
|
+
it "returns true if the text field is disabled" do
|
161
|
+
@browser.text_field(:id, 'new_user_species').should be_disabled
|
162
|
+
end
|
163
|
+
|
164
|
+
it "returns false if the text field is enabled" do
|
165
|
+
@browser.text_field(:index, 1).should_not be_disabled
|
166
|
+
end
|
167
|
+
|
168
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
169
|
+
lambda { @browser.text_field(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe "#readonly?" do
|
174
|
+
it "returns true for read-only text fields" do
|
175
|
+
@browser.text_field(:name, "new_user_code").should be_readonly
|
176
|
+
@browser.text_field(:id, "new_user_code").should be_readonly
|
177
|
+
end
|
178
|
+
|
179
|
+
it "returns false for writeable text fields" do
|
180
|
+
@browser.text_field(:name, "new_user_email").should_not be_readonly
|
181
|
+
end
|
182
|
+
|
183
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
184
|
+
lambda { @browser.text_field(:id, 'no_such_id').readonly? }.should raise_error(UnknownObjectException)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
# Manipulation methods
|
190
|
+
describe "#append" do
|
191
|
+
it "appends the text to the text field" do
|
192
|
+
@browser.text_field(:name, "new_user_occupation").append(" Append This")
|
193
|
+
@browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer Append This"
|
194
|
+
end
|
195
|
+
|
196
|
+
it "appends multi-byte characters" do
|
197
|
+
@browser.text_field(:name, "new_user_occupation").append(" ijij")
|
198
|
+
@browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer ijij"
|
199
|
+
end
|
200
|
+
|
201
|
+
it "raises ObjectReadOnlyException if the object is read only" do
|
202
|
+
lambda { @browser.text_field(:id, "new_user_code").append("Append This") }.should raise_error(ObjectReadOnlyException)
|
203
|
+
end
|
204
|
+
|
205
|
+
it "raises ObjectDisabledException if the object is disabled" do
|
206
|
+
lambda { @browser.text_field(:name, "new_user_species").append("Append This") }.should raise_error(ObjectDisabledException)
|
207
|
+
end
|
208
|
+
|
209
|
+
it "raises UnknownObjectException if the object doesn't exist" do
|
210
|
+
lambda { @browser.text_field(:name, "no_such_name").append("Append This") }.should raise_error(UnknownObjectException)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "#clear" do
|
215
|
+
it "removes all text from the text field" do
|
216
|
+
@browser.text_field(:name, "new_user_occupation").clear
|
217
|
+
@browser.text_field(:name, "new_user_occupation").get_contents.should be_empty
|
218
|
+
@browser.text_field(:id, "delete_user_comment").clear
|
219
|
+
@browser.text_field(:id, "delete_user_comment").get_contents.should be_empty
|
220
|
+
end
|
221
|
+
|
222
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
223
|
+
lambda { @browser.text_field(:id, "no_such_id").clear }.should raise_error(UnknownObjectException)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe "#drag_contents_to" do
|
228
|
+
it "drags contents to another text field" do
|
229
|
+
@browser.text_field(:name, "new_user_first_name").set("Smith")
|
230
|
+
@browser.text_field(:name, "new_user_first_name").drag_contents_to(:name, "new_user_last_name")
|
231
|
+
@browser.text_field(:name, "new_user_first_name").value.should be_empty
|
232
|
+
@browser.text_field(:id, "new_user_last_name").value.should == "Smith"
|
233
|
+
end
|
234
|
+
|
235
|
+
it "raises UnknownObjectException if either of the text fields doesn't exist" do
|
236
|
+
lambda { @browser.text_field(:id, "no_such_id").drag_contents_to(:name, "new_user_last_name") }.should raise_error(UnknownObjectException)
|
237
|
+
lambda { @browser.text_field(:name, "new_user_first_name").drag_contents_to(:id, "no_such_id") }.should raise_error(UnknownObjectException)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "#get_contents" do
|
242
|
+
it "returns the contents of the text field" do
|
243
|
+
@browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer"
|
244
|
+
end
|
245
|
+
|
246
|
+
it "raises UnknownObjectException when accessing a non-existing element" do
|
247
|
+
lambda { @browser.text_field(:name, "no_such_name").get_contents }.should raise_error(UnknownObjectException)
|
248
|
+
end
|
249
|
+
|
250
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
251
|
+
lambda { @browser.text_field(:id, "no_such_id").get_contents }.should raise_error(UnknownObjectException)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "#value=" do
|
256
|
+
it "sets the value of the element" do
|
257
|
+
@browser.text_field(:id, 'new_user_email').value = 'Hello Cruel World'
|
258
|
+
@browser.text_field(:id, "new_user_email").value.should == 'Hello Cruel World'
|
259
|
+
end
|
260
|
+
|
261
|
+
it "is able to set multi-byte characters" do
|
262
|
+
@browser.text_field(:name, "new_user_occupation").value = "ijij"
|
263
|
+
@browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
|
264
|
+
end
|
265
|
+
|
266
|
+
it "sets the value of a textarea element" do
|
267
|
+
@browser.text_field(:id, 'delete_user_comment').value = 'Hello Cruel World'
|
268
|
+
@browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
|
269
|
+
end
|
270
|
+
|
271
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
272
|
+
lambda { @browser.text_field(:name, "no_such_name").value = 'yo' }.should raise_error(UnknownObjectException)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
describe "#set" do
|
277
|
+
it "sets the value of the element" do
|
278
|
+
@browser.text_field(:id, 'new_user_email').set('Bye Cruel World')
|
279
|
+
@browser.text_field(:id, "new_user_email").value.should == 'Bye Cruel World'
|
280
|
+
end
|
281
|
+
|
282
|
+
it "sets the value of a textarea element" do
|
283
|
+
@browser.text_field(:id, 'delete_user_comment').set('Hello Cruel World')
|
284
|
+
@browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
|
285
|
+
end
|
286
|
+
|
287
|
+
it "fires events" do
|
288
|
+
@browser.text_field(:id, "new_user_username").set("Hello World")
|
289
|
+
@browser.span(:id, "current_length").text.should == "11"
|
290
|
+
end
|
291
|
+
|
292
|
+
it "sets the value of a password field" do
|
293
|
+
@browser.text_field(:name , 'new_user_password').set('secret')
|
294
|
+
@browser.text_field(:name , 'new_user_password').value.should == 'secret'
|
295
|
+
end
|
296
|
+
|
297
|
+
it "sets the value when accessed through the enclosing Form" do
|
298
|
+
@browser.form(:id, 'new_user').text_field(:name , 'new_user_password').set('secret')
|
299
|
+
end
|
300
|
+
|
301
|
+
it "is able to set multi-byte characters" do
|
302
|
+
@browser.text_field(:name, "new_user_occupation").set("ijij")
|
303
|
+
@browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
|
304
|
+
end
|
305
|
+
|
306
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
307
|
+
lambda { @browser.text_field(:id, "no_such_id").set('secret') }.should raise_error(UnknownObjectException)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe "#verify_contains" do
|
312
|
+
it "verifys that a text field contains its value" do
|
313
|
+
@browser.text_field(:name, "new_user_occupation").verify_contains("Developer").should be_true
|
314
|
+
@browser.text_field(:name, "new_user_occupation").verify_contains(/Developer/).should be_true
|
315
|
+
end
|
316
|
+
|
317
|
+
it "doesn't verify that a text field contains a non-existing value" do
|
318
|
+
@browser.text_field(:name, "new_user_email").verify_contains("no_such_text").should be_false
|
319
|
+
@browser.text_field(:name, "new_user_email").verify_contains(/no_such_text/).should be_false
|
320
|
+
end
|
321
|
+
|
322
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
323
|
+
lambda { @browser.text_field(:id, "no_such_id").verify_contains("Developer") }.should raise_error(UnknownObjectException)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
after :all do
|
328
|
+
@browser.close
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "TextFields" 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 text fields" do
|
15
|
+
@browser.text_fields.length.should == 9
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#[]" do
|
20
|
+
it "returns the text field at the given index" do
|
21
|
+
@browser.text_fields[1].id.should == "new_user_first_name"
|
22
|
+
@browser.text_fields[2].id.should == "new_user_last_name"
|
23
|
+
@browser.text_fields[3].id.should == "new_user_email"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#each" do
|
28
|
+
it "iterates through text fields correctly" do
|
29
|
+
index = 1
|
30
|
+
@browser.text_fields.each do |r|
|
31
|
+
r.name.should == @browser.text_field(:index, index).name
|
32
|
+
r.id.should == @browser.text_field(:index, index).id
|
33
|
+
r.value.should == @browser.text_field(:index, index).value
|
34
|
+
index += 1
|
35
|
+
end
|
36
|
+
@browser.text_fields.length.should == index - 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
after :all do
|
41
|
+
@browser.close
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/spec/ul_spec.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Ul" 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 "#exist?" do
|
15
|
+
it "returns true if the 'ul' exists" do
|
16
|
+
@browser.ul(:id, "navbar").should exist
|
17
|
+
@browser.ul(:id, /navbar/).should exist
|
18
|
+
@browser.ul(:index, 1).should exist
|
19
|
+
@browser.ul(:xpath, "//ul[@id='navbar']").should exist
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns true if the element exists (default how = :id)" do
|
23
|
+
@browser.ul("navbar").should exist
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns false if the 'ul' doesn't exist" do
|
27
|
+
@browser.ul(:id, "no_such_id").should_not exist
|
28
|
+
@browser.ul(:id, /no_such_id/).should_not exist
|
29
|
+
@browser.ul(:text, "no_such_text").should_not exist
|
30
|
+
@browser.ul(:text, /no_such_text/).should_not exist
|
31
|
+
@browser.ul(:class, "no_such_class").should_not exist
|
32
|
+
@browser.ul(:class, /no_such_class/).should_not exist
|
33
|
+
@browser.ul(:index, 1337).should_not exist
|
34
|
+
@browser.ul(:xpath, "//ul[@id='no_such_id']").should_not exist
|
35
|
+
end
|
36
|
+
|
37
|
+
it "raises TypeError when 'what' argument is invalid" do
|
38
|
+
lambda { @browser.ul(:id, 3.14).exists? }.should raise_error(TypeError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
42
|
+
lambda { @browser.ul(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Attribute methods
|
47
|
+
describe "#class_name" do
|
48
|
+
it "returns the class attribute" do
|
49
|
+
@browser.ul(:id, 'navbar').class_name.should == 'navigation'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
53
|
+
@browser.ul(:index, 2).class_name.should == ''
|
54
|
+
end
|
55
|
+
|
56
|
+
it "raises UnknownObjectException if the ul doesn't exist" do
|
57
|
+
lambda { @browser.ul(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#id" do
|
62
|
+
it "returns the id attribute" do
|
63
|
+
@browser.ul(:class, 'navigation').id.should == "navbar"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
67
|
+
@browser.ul(:index, 2).id.should == ''
|
68
|
+
end
|
69
|
+
|
70
|
+
it "raises UnknownObjectException if the ul doesn't exist" do
|
71
|
+
lambda { @browser.ul(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
72
|
+
lambda { @browser.ul(:index, 1337).id }.should raise_error(UnknownObjectException)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#respond_to?" do
|
77
|
+
it "returns true for all attribute methods" do
|
78
|
+
@browser.ul(:index, 1).should respond_to(:class_name)
|
79
|
+
@browser.ul(:index, 1).should respond_to(:id)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
after :all do
|
85
|
+
@browser.close
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|