celerity 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/History.txt +14 -0
- data/Manifest.txt +127 -151
- data/README.txt +15 -20
- data/lib/celerity.rb +13 -5
- data/lib/celerity/browser.rb +296 -0
- data/lib/celerity/clickable_element.rb +1 -0
- data/lib/celerity/collections.rb +4 -0
- data/lib/celerity/container.rb +69 -2
- data/lib/celerity/disabled_element.rb +1 -0
- data/lib/celerity/element.rb +103 -38
- data/lib/celerity/element_collections.rb +14 -8
- data/lib/celerity/element_locator.rb +61 -50
- data/lib/celerity/element_map.rb +51 -0
- data/lib/celerity/elements/button.rb +1 -0
- data/lib/celerity/elements/file_field.rb +3 -2
- data/lib/celerity/elements/form.rb +1 -0
- data/lib/celerity/elements/frame.rb +16 -1
- data/lib/celerity/elements/image.rb +15 -13
- data/lib/celerity/elements/link.rb +4 -1
- data/lib/celerity/elements/option.rb +1 -0
- data/lib/celerity/elements/radio_check.rb +19 -7
- data/lib/celerity/elements/select_list.rb +17 -2
- data/lib/celerity/elements/table.rb +34 -20
- data/lib/celerity/elements/table_body.rb +2 -2
- data/lib/celerity/elements/table_cell.rb +3 -1
- data/lib/celerity/elements/table_footer.rb +2 -2
- data/lib/celerity/elements/table_header.rb +2 -2
- data/lib/celerity/elements/table_row.rb +4 -2
- data/lib/celerity/elements/text_field.rb +20 -9
- data/lib/celerity/exception.rb +11 -18
- data/lib/celerity/extra/method_generator.rb +13 -8
- data/lib/celerity/htmlunit/download.sh +23 -0
- data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
- data/lib/celerity/htmlunit/{nekohtml-1.9.7.jar → nekohtml-1.9.8.jar} +0 -0
- data/lib/celerity/input_element.rb +1 -1
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +37 -23
- data/spec/area_spec.rb +19 -4
- data/spec/areas_spec.rb +2 -3
- data/spec/{ie_spec.rb → browser_spec.rb} +66 -15
- data/spec/button_spec.rb +36 -3
- data/spec/buttons_spec.rb +2 -3
- data/spec/checkbox_spec.rb +43 -8
- data/spec/checkboxes_spec.rb +2 -3
- data/spec/div_spec.rb +31 -4
- data/spec/divs_spec.rb +2 -3
- data/spec/element_spec.rb +36 -6
- data/spec/filefield_spec.rb +28 -13
- data/spec/filefields_spec.rb +2 -3
- data/spec/form_spec.rb +6 -3
- data/spec/forms_spec.rb +2 -3
- data/spec/frame_spec.rb +14 -5
- data/spec/frames_spec.rb +71 -0
- data/spec/hidden_spec.rb +21 -3
- data/spec/hiddens_spec.rb +2 -3
- data/spec/hn_spec.rb +30 -12
- data/spec/hns_spec.rb +14 -10
- data/spec/html/form_js_bug.html +11 -0
- data/spec/html/forms_with_input_elements.html +2 -1
- data/spec/html/invalid_js.html +11 -0
- data/spec/html/latin1_text.html +1 -0
- data/spec/html/non_control_elements.html +8 -4
- data/spec/html/simple_ajax.html +22 -0
- data/spec/htmlunit_spec.rb +4 -5
- data/spec/image_spec.rb +33 -3
- data/spec/images_spec.rb +2 -3
- data/spec/label_spec.rb +16 -3
- data/spec/labels_spec.rb +2 -3
- data/spec/li_spec.rb +25 -3
- data/spec/link_spec.rb +35 -3
- data/spec/links_spec.rb +2 -3
- data/spec/lis_spec.rb +2 -3
- data/spec/map_spec.rb +19 -3
- data/spec/maps_spec.rb +2 -3
- data/spec/meta_spec.rb +3 -1
- data/spec/ol_spec.rb +17 -3
- data/spec/ols_spec.rb +2 -3
- data/spec/option_spec.rb +28 -3
- data/spec/p_spec.rb +30 -2
- data/spec/pre_spec.rb +25 -3
- data/spec/pres_spec.rb +2 -3
- data/spec/ps_spec.rb +2 -3
- data/spec/radio_spec.rb +47 -3
- data/spec/radios_spec.rb +2 -3
- data/spec/select_list_spec.rb +42 -3
- data/spec/select_lists_spec.rb +2 -3
- data/spec/span_spec.rb +32 -7
- data/spec/spans_spec.rb +2 -4
- data/spec/spec_helper.rb +5 -25
- data/spec/table_bodies_spec.rb +7 -5
- data/spec/table_body_spec.rb +11 -4
- data/spec/table_cell_spec.rb +15 -4
- data/spec/table_cells_spec.rb +3 -4
- data/spec/table_footer_spec.rb +11 -4
- data/spec/table_footers_spec.rb +7 -5
- data/spec/table_header_spec.rb +11 -4
- data/spec/table_headers_spec.rb +7 -5
- data/spec/table_row_spec.rb +31 -7
- data/spec/table_rows_spec.rb +5 -4
- data/spec/table_spec.rb +36 -7
- data/spec/tables_spec.rb +2 -3
- data/spec/text_field_spec.rb +51 -13
- data/spec/text_fields_spec.rb +2 -3
- data/spec/ul_spec.rb +18 -3
- data/spec/uls_spec.rb +2 -3
- data/spec/{watir_compatability_spec.rb → watir_compatibility_spec.rb} +42 -35
- data/support/spec_server.rb +9 -0
- metadata +167 -161
- metadata.gz.sig +0 -0
- data/benchmark/bm_2000_spans.rb +0 -48
- data/benchmark/bm_digg.rb +0 -26
- data/benchmark/bm_google_images.rb +0 -36
- data/benchmark/bm_input_locator.rb +0 -69
- data/benchmark/loader.rb +0 -9
- data/config/hoe.rb +0 -68
- data/config/requirements.rb +0 -15
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
- data/lib/celerity/ie.rb +0 -195
- data/setup.rb +0 -1583
- data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +0 -37
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +0 -19
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
- data/support/celerity_viewer/rubycocoa/Info.plist.erb +0 -28
- data/support/celerity_viewer/rubycocoa/MainController.rb +0 -23
- data/support/celerity_viewer/rubycocoa/README +0 -94
- data/support/celerity_viewer/rubycocoa/Rakefile +0 -100
- data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +0 -86
- data/support/celerity_viewer/rubycocoa/main.m +0 -7
- data/support/celerity_viewer/rubycocoa/main.rb +0 -27
- data/tasks/benchmark.rake +0 -4
- data/tasks/environment.rake +0 -7
- data/tasks/simple_ci.rake +0 -94
data/spec/link_spec.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
|
3
|
-
describe Link do
|
|
3
|
+
describe "Link" do
|
|
4
4
|
|
|
5
5
|
before :all do
|
|
6
|
-
@browser =
|
|
7
|
-
add_spec_checker(@browser)
|
|
6
|
+
@browser = Browser.new
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
before :each do
|
|
@@ -27,9 +26,11 @@ describe Link do
|
|
|
27
26
|
@browser.link(:index, 2).should exist
|
|
28
27
|
@browser.link(:xpath, "//a[@id='link_2']").should exist
|
|
29
28
|
end
|
|
29
|
+
|
|
30
30
|
it "should return true if the element exists (default how = :href)" do
|
|
31
31
|
@browser.link(/input_elements/).should exist
|
|
32
32
|
end
|
|
33
|
+
|
|
33
34
|
it "should return false if the link doesn't exist" do
|
|
34
35
|
@browser.link(:id, 'no_such_id').should_not exist
|
|
35
36
|
@browser.link(:id, /no_such_id/).should_not exist
|
|
@@ -44,9 +45,11 @@ describe Link do
|
|
|
44
45
|
@browser.link(:index, 1337).should_not exist
|
|
45
46
|
@browser.link(:xpath, "//a[@id='no_such_id']").should_not exist
|
|
46
47
|
end
|
|
48
|
+
|
|
47
49
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
|
48
50
|
lambda { @browser.link(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
49
51
|
end
|
|
52
|
+
|
|
50
53
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
|
51
54
|
lambda { @browser.link(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
52
55
|
end
|
|
@@ -57,9 +60,11 @@ describe Link do
|
|
|
57
60
|
it "should return the type attribute if the link exists" do
|
|
58
61
|
@browser.link(:index, 2).class_name.should == "external"
|
|
59
62
|
end
|
|
63
|
+
|
|
60
64
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
61
65
|
@browser.link(:index, 1).class_name.should == ''
|
|
62
66
|
end
|
|
67
|
+
|
|
63
68
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
64
69
|
lambda { @browser.link(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
|
65
70
|
end
|
|
@@ -69,9 +74,11 @@ describe Link do
|
|
|
69
74
|
it "should return the href attribute if the link exists" do
|
|
70
75
|
@browser.link(:index, 2).href.should match(/non_control_elements/)
|
|
71
76
|
end
|
|
77
|
+
|
|
72
78
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
73
79
|
@browser.link(:index, 1).href.should == ""
|
|
74
80
|
end
|
|
81
|
+
|
|
75
82
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
76
83
|
lambda { @browser.link(:index, 1337).href }.should raise_error(UnknownObjectException)
|
|
77
84
|
end
|
|
@@ -87,9 +94,11 @@ describe Link do
|
|
|
87
94
|
it "should return the id attribute if the link exists" do
|
|
88
95
|
@browser.link(:index, 2).id.should == "link_2"
|
|
89
96
|
end
|
|
97
|
+
|
|
90
98
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
91
99
|
@browser.link(:index, 1).id.should == ""
|
|
92
100
|
end
|
|
101
|
+
|
|
93
102
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
94
103
|
lambda { @browser.link(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
95
104
|
end
|
|
@@ -99,9 +108,11 @@ describe Link do
|
|
|
99
108
|
it "should return the name attribute if the link exists" do
|
|
100
109
|
@browser.link(:index, 3).name.should == "bad_attribute"
|
|
101
110
|
end
|
|
111
|
+
|
|
102
112
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
103
113
|
@browser.link(:index, 1).name.should == ''
|
|
104
114
|
end
|
|
115
|
+
|
|
105
116
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
106
117
|
lambda { @browser.link(:index, 1337).name }.should raise_error(UnknownObjectException)
|
|
107
118
|
end
|
|
@@ -111,9 +122,11 @@ describe Link do
|
|
|
111
122
|
it "should return the link text" do
|
|
112
123
|
@browser.link(:index, 2).text.should == "Link 2"
|
|
113
124
|
end
|
|
125
|
+
|
|
114
126
|
it "should return an empty string if the link exists and contains no text" do
|
|
115
127
|
@browser.link(:index, 1).text.should == ""
|
|
116
128
|
end
|
|
129
|
+
|
|
117
130
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
118
131
|
lambda { @browser.link(:index, 1337).text }.should raise_error(UnknownObjectException)
|
|
119
132
|
end
|
|
@@ -123,28 +136,47 @@ describe Link do
|
|
|
123
136
|
it "should return the type attribute if the link exists" do
|
|
124
137
|
@browser.link(:index, 2).title.should == "link_title_2"
|
|
125
138
|
end
|
|
139
|
+
|
|
126
140
|
it "should return an empty string if the link exists and the attribute doesn't" do
|
|
127
141
|
@browser.link(:index, 1).title.should == ""
|
|
128
142
|
end
|
|
143
|
+
|
|
129
144
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
130
145
|
lambda { @browser.link(:index, 1337).title }.should raise_error(UnknownObjectException)
|
|
131
146
|
end
|
|
132
147
|
end
|
|
133
148
|
|
|
149
|
+
describe "#respond_to?" do
|
|
150
|
+
it "should return true for all attribute methods" do
|
|
151
|
+
@browser.link(:index, 1).should respond_to(:class_name)
|
|
152
|
+
@browser.link(:index, 1).should respond_to(:href)
|
|
153
|
+
@browser.link(:index, 1).should respond_to(:url)
|
|
154
|
+
@browser.link(:index, 1).should respond_to(:id)
|
|
155
|
+
@browser.link(:index, 1).should respond_to(:name)
|
|
156
|
+
@browser.link(:index, 1).should respond_to(:style)
|
|
157
|
+
@browser.link(:index, 1).should respond_to(:text)
|
|
158
|
+
@browser.link(:index, 1).should respond_to(:title)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
|
|
134
163
|
# Manipulation methods
|
|
135
164
|
describe "#click" do
|
|
136
165
|
it "should find an existing link by (:text, String) and click it" do
|
|
137
166
|
@browser.link(:text, "Link 3").click
|
|
138
167
|
@browser.text.include?("User administration").should be_true
|
|
139
168
|
end
|
|
169
|
+
|
|
140
170
|
it "should find an existing link by (:text, Regexp) and click it" do
|
|
141
171
|
@browser.link(:url, /forms_with_input_elements/).click
|
|
142
172
|
@browser.text.include?("User administration").should be_true
|
|
143
173
|
end
|
|
174
|
+
|
|
144
175
|
it "should find an existing link by (:index, Integer) and click it" do
|
|
145
176
|
@browser.link(:index, 3).click
|
|
146
177
|
@browser.text.include?("User administration").should be_true
|
|
147
178
|
end
|
|
179
|
+
|
|
148
180
|
it "should raise an UnknownObjectException if the link doesn't exist" do
|
|
149
181
|
lambda { @browser.link(:index, 1337).click }.should raise_error(UnknownObjectException)
|
|
150
182
|
end
|
data/spec/links_spec.rb
CHANGED
data/spec/lis_spec.rb
CHANGED
data/spec/map_spec.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
|
3
|
-
describe Map do
|
|
3
|
+
describe "Map" do
|
|
4
4
|
|
|
5
5
|
before :all do
|
|
6
|
-
@browser =
|
|
7
|
-
add_spec_checker(@browser)
|
|
6
|
+
@browser = Browser.new
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
before :each do
|
|
@@ -21,9 +20,11 @@ describe Map do
|
|
|
21
20
|
@browser.map(:index, 1).should exist
|
|
22
21
|
@browser.map(:xpath, "//map[@id='triangle_map']").should exist
|
|
23
22
|
end
|
|
23
|
+
|
|
24
24
|
it "should return true if the element exists (default how = :id)" do
|
|
25
25
|
@browser.map("triangle_map").should exist
|
|
26
26
|
end
|
|
27
|
+
|
|
27
28
|
it "should return false if the 'map' doesn't exist" do
|
|
28
29
|
@browser.map(:id, "no_such_id").should_not exist
|
|
29
30
|
@browser.map(:id, /no_such_id/).should_not exist
|
|
@@ -32,9 +33,11 @@ describe Map do
|
|
|
32
33
|
@browser.map(:index, 1337).should_not exist
|
|
33
34
|
@browser.map(:xpath, "//map[@id='no_such_id']").should_not exist
|
|
34
35
|
end
|
|
36
|
+
|
|
35
37
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
|
36
38
|
lambda { @browser.map(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
37
39
|
end
|
|
40
|
+
|
|
38
41
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
|
39
42
|
lambda { @browser.map(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
40
43
|
end
|
|
@@ -45,9 +48,11 @@ describe Map do
|
|
|
45
48
|
it "should return the id attribute" do
|
|
46
49
|
@browser.map(:index, 1).id.should == "triangle_map"
|
|
47
50
|
end
|
|
51
|
+
|
|
48
52
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
|
49
53
|
@browser.map(:index, 2).id.should == ''
|
|
50
54
|
end
|
|
55
|
+
|
|
51
56
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
|
52
57
|
lambda { @browser.map(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
|
53
58
|
lambda { @browser.map(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
@@ -58,14 +63,24 @@ describe Map do
|
|
|
58
63
|
it "should return the name attribute" do
|
|
59
64
|
@browser.map(:index, 1).name.should == "triangle_map"
|
|
60
65
|
end
|
|
66
|
+
|
|
61
67
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
|
62
68
|
@browser.map(:index, 2).name.should == ''
|
|
63
69
|
end
|
|
70
|
+
|
|
64
71
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
|
65
72
|
lambda { @browser.map(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
|
66
73
|
lambda { @browser.map(:index, 1337).name }.should raise_error(UnknownObjectException)
|
|
67
74
|
end
|
|
68
75
|
end
|
|
76
|
+
|
|
77
|
+
describe "#respond_to?" do
|
|
78
|
+
it "should return true for all attribute methods" do
|
|
79
|
+
@browser.map(:index, 1).should respond_to(:id)
|
|
80
|
+
@browser.map(:index, 1).should respond_to(:name)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
69
84
|
|
|
70
85
|
# Other
|
|
71
86
|
describe "#to_s" do
|
|
@@ -74,6 +89,7 @@ describe Map do
|
|
|
74
89
|
" id: triangle_map\n" +
|
|
75
90
|
" name: triangle_map"
|
|
76
91
|
end
|
|
92
|
+
|
|
77
93
|
it "should raise UnknownObjectException if the p doesn't exist" do
|
|
78
94
|
lambda { @browser.map(:xpath, "//map[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
|
|
79
95
|
end
|
data/spec/maps_spec.rb
CHANGED
data/spec/meta_spec.rb
CHANGED
data/spec/ol_spec.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
|
3
|
-
describe Ul do
|
|
3
|
+
describe "Ul" do
|
|
4
4
|
|
|
5
5
|
before :all do
|
|
6
|
-
@browser =
|
|
7
|
-
add_spec_checker(@browser)
|
|
6
|
+
@browser = Browser.new
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
before :each do
|
|
@@ -19,9 +18,11 @@ describe Ul do
|
|
|
19
18
|
@browser.ol(:index, 1).should exist
|
|
20
19
|
@browser.ol(:xpath, "//ol[@id='favorite_compounds']").should exist
|
|
21
20
|
end
|
|
21
|
+
|
|
22
22
|
it "should return true if the element exists (default how = :id)" do
|
|
23
23
|
@browser.ol("favorite_compounds").should exist
|
|
24
24
|
end
|
|
25
|
+
|
|
25
26
|
it "should return false if the 'ol' doesn't exist" do
|
|
26
27
|
@browser.ol(:id, "no_such_id").should_not exist
|
|
27
28
|
@browser.ol(:id, /no_such_id/).should_not exist
|
|
@@ -32,9 +33,11 @@ describe Ul do
|
|
|
32
33
|
@browser.ol(:index, 1337).should_not exist
|
|
33
34
|
@browser.ol(:xpath, "//ol[@id='no_such_id']").should_not exist
|
|
34
35
|
end
|
|
36
|
+
|
|
35
37
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
|
36
38
|
lambda { @browser.ol(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
37
39
|
end
|
|
40
|
+
|
|
38
41
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
|
39
42
|
lambda { @browser.ol(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
40
43
|
end
|
|
@@ -45,9 +48,11 @@ describe Ul do
|
|
|
45
48
|
it "should return the class attribute" do
|
|
46
49
|
@browser.ol(:id, 'favorite_compounds').class_name.should == 'chemistry'
|
|
47
50
|
end
|
|
51
|
+
|
|
48
52
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
|
49
53
|
@browser.ol(:index, 2).class_name.should == ''
|
|
50
54
|
end
|
|
55
|
+
|
|
51
56
|
it "should raise UnknownObjectException if the ol doesn't exist" do
|
|
52
57
|
lambda { @browser.ol(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
|
53
58
|
end
|
|
@@ -57,15 +62,24 @@ describe Ul do
|
|
|
57
62
|
it "should return the id attribute" do
|
|
58
63
|
@browser.ol(:class, 'chemistry').id.should == "favorite_compounds"
|
|
59
64
|
end
|
|
65
|
+
|
|
60
66
|
it "should return an empty string if the element exists and the attribute doesn't" do
|
|
61
67
|
@browser.ol(:index, 2).id.should == ''
|
|
62
68
|
end
|
|
69
|
+
|
|
63
70
|
it "should raise UnknownObjectException if the ol doesn't exist" do
|
|
64
71
|
lambda { @browser.ol(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
|
65
72
|
lambda { @browser.ol(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
66
73
|
end
|
|
67
74
|
end
|
|
68
75
|
|
|
76
|
+
describe "#respond_to?" do
|
|
77
|
+
it "should return true for all attribute methods" do
|
|
78
|
+
@browser.ol(:index, 1).should respond_to(:class_name)
|
|
79
|
+
@browser.ol(:index, 1).should respond_to(:id)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
69
83
|
after :all do
|
|
70
84
|
@browser.close
|
|
71
85
|
end
|
data/spec/ols_spec.rb
CHANGED
data/spec/option_spec.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
|
3
|
-
describe Option do
|
|
3
|
+
describe "Option" do
|
|
4
4
|
|
|
5
5
|
before :all do
|
|
6
|
-
@browser =
|
|
7
|
-
add_spec_checker(@browser)
|
|
6
|
+
@browser = Browser.new
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
before :each do
|
|
@@ -23,6 +22,7 @@ describe Option do
|
|
|
23
22
|
@browser.option(:index, 2).should exist
|
|
24
23
|
@browser.option(:xpath, "//option[@id='nor']").should exist
|
|
25
24
|
end
|
|
25
|
+
|
|
26
26
|
it "should return true if the element exists (select_list context)" do
|
|
27
27
|
@browser.select_list(:name, "new_user_country").option(:id, "nor").should exist
|
|
28
28
|
@browser.select_list(:name, "new_user_country").option(:id, /nor/).should exist
|
|
@@ -34,10 +34,12 @@ describe Option do
|
|
|
34
34
|
@browser.select_list(:name, "new_user_country").option(:index, 2).should exist
|
|
35
35
|
@browser.select_list(:name, "new_user_country").option(:xpath, "//option[@id='nor']").should exist
|
|
36
36
|
end
|
|
37
|
+
|
|
37
38
|
it "should return true if the element exists (default how = :text)" do
|
|
38
39
|
@browser.option("Swedish").should exist
|
|
39
40
|
@browser.select_list(:name, "new_user_languages").option("Swedish").should exist
|
|
40
41
|
end
|
|
42
|
+
|
|
41
43
|
it "should return false if the element does not exist (page context)" do
|
|
42
44
|
@browser.option(:id, "no_such_id").should_not exist
|
|
43
45
|
@browser.option(:id, /no_such_id/).should_not exist
|
|
@@ -49,6 +51,7 @@ describe Option do
|
|
|
49
51
|
@browser.option(:index, 1337).should_not exist
|
|
50
52
|
@browser.option(:xpath, "//option[@id='no_such_id']").should_not exist
|
|
51
53
|
end
|
|
54
|
+
|
|
52
55
|
it "should return false if the element does not exist (select_list context)" do
|
|
53
56
|
@browser.select_list(:name, "new_user_country").option(:id, "no_such_id").should_not exist
|
|
54
57
|
@browser.select_list(:name, "new_user_country").option(:id, /no_such_id/).should_not exist
|
|
@@ -60,10 +63,12 @@ describe Option do
|
|
|
60
63
|
@browser.select_list(:name, "new_user_country").option(:index, 1337).should_not exist
|
|
61
64
|
@browser.select_list(:name, "new_user_country").option(:xpath, "//option[@id='no_such_id']").should_not exist
|
|
62
65
|
end
|
|
66
|
+
|
|
63
67
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
|
64
68
|
lambda { @browser.option(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
65
69
|
lambda { @browser.select_list(:name, "new_user_country").option(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
66
70
|
end
|
|
71
|
+
|
|
67
72
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
|
68
73
|
lambda { @browser.option(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
69
74
|
lambda { @browser.select_list(:name, "new_user_country").option(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
@@ -76,38 +81,47 @@ describe Option do
|
|
|
76
81
|
@browser.option(:text, "Denmark").select
|
|
77
82
|
@browser.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
|
|
78
83
|
end
|
|
84
|
+
|
|
79
85
|
it "should should be able to select the chosen option (select_list context)" do
|
|
80
86
|
@browser.select_list(:name, "new_user_country").clear_selection
|
|
81
87
|
@browser.select_list(:name, "new_user_country").option(:text, "Denmark").select
|
|
82
88
|
@browser.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
|
|
83
89
|
end
|
|
90
|
+
|
|
84
91
|
it "should select the option when found by text (page context)" do
|
|
85
92
|
@browser.option(:text, 'Sweden').select
|
|
86
93
|
@browser.option(:text, 'Sweden').should be_selected
|
|
87
94
|
end
|
|
95
|
+
|
|
88
96
|
it "should select the option when found by text (select_list context)" do
|
|
89
97
|
@browser.select_list(:name, 'new_user_country').option(:text, 'Sweden').select
|
|
90
98
|
@browser.select_list(:name, 'new_user_country').option(:text, 'Sweden').should be_selected
|
|
91
99
|
end
|
|
100
|
+
|
|
92
101
|
it "should fire onclick event (page context)" do
|
|
93
102
|
@browser.option(:text, "Username 3").select
|
|
94
103
|
@browser.text_field(:id, 'delete_user_comment').value.should == 'Don\'t do it!'
|
|
95
104
|
end
|
|
105
|
+
|
|
96
106
|
it "should fire onclick event (select_list context)" do
|
|
97
107
|
@browser.select_list(:id, 'delete_user_username').option(:text, "Username 3").select
|
|
98
108
|
@browser.text_field(:id, 'delete_user_comment').value.should == 'Don\'t do it!'
|
|
99
109
|
end
|
|
110
|
+
|
|
100
111
|
it "should raise UnknownObjectException if the option does not exist (page context)" do
|
|
101
112
|
lambda { @browser.option(:text, "no_such_text").select }.should raise_error(UnknownObjectException)
|
|
102
113
|
lambda { @browser.option(:text, /missing/).select }.should raise_error(UnknownObjectException)
|
|
103
114
|
end
|
|
115
|
+
|
|
104
116
|
it "should raise UnknownObjectException if the option does not exist (select_list context)" do
|
|
105
117
|
lambda { @browser.select_list(:name, "new_user_country").option(:text, "no_such_text").select }.should raise_error(UnknownObjectException)
|
|
106
118
|
lambda { @browser.select_list(:name, "new_user_country").option(:text, /missing/).select }.should raise_error(UnknownObjectException)
|
|
107
119
|
end
|
|
120
|
+
|
|
108
121
|
it "should raise MissingWayOfFindingObjectException when given a bad 'how' (page context)" do
|
|
109
122
|
lambda { @browser.option(:missing, "Denmark").select }.should raise_error(MissingWayOfFindingObjectException)
|
|
110
123
|
end
|
|
124
|
+
|
|
111
125
|
it "should raise MissingWayOfFindingObjectException when given a bad 'how' (select_list context)" do
|
|
112
126
|
lambda { @browser.select_list(:name, "new_user_country").option(:missing, "Denmark").select }.should raise_error(MissingWayOfFindingObjectException)
|
|
113
127
|
end
|
|
@@ -117,10 +131,21 @@ describe Option do
|
|
|
117
131
|
it "should be able to get attributes (page context)" do
|
|
118
132
|
@browser.option(:text, 'Sweden').class_name.should == "scandinavia"
|
|
119
133
|
end
|
|
134
|
+
|
|
120
135
|
it "should be able to get attributes (select_list context)" do
|
|
121
136
|
@browser.select_list(:name, "new_user_country").option(:text , 'Sweden').class_name.should == "scandinavia"
|
|
122
137
|
end
|
|
123
138
|
end
|
|
139
|
+
|
|
140
|
+
describe "#respond_to?" do
|
|
141
|
+
it "should return true for all attribute methods" do
|
|
142
|
+
@browser.option(:index, 1).should respond_to(:class_name)
|
|
143
|
+
@browser.option(:index, 1).should respond_to(:id)
|
|
144
|
+
@browser.option(:index, 1).should respond_to(:text)
|
|
145
|
+
@browser.option(:index, 1).should respond_to(:name)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
124
149
|
|
|
125
150
|
after :all do
|
|
126
151
|
@browser.close
|