celerity 0.0.4 → 0.0.6
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/History.txt +33 -0
- data/README.txt +19 -9
- data/Rakefile +9 -3
- data/lib/celerity.rb +39 -39
- data/lib/celerity/browser.rb +538 -153
- data/lib/celerity/clickable_element.rb +48 -7
- data/lib/celerity/collections.rb +155 -131
- data/lib/celerity/container.rb +766 -385
- data/lib/celerity/default_viewer.rb +10 -0
- data/lib/celerity/disabled_element.rb +19 -2
- data/lib/celerity/element.rb +152 -83
- data/lib/celerity/element_collection.rb +106 -0
- data/lib/celerity/element_locator.rb +89 -66
- data/lib/celerity/elements/button.rb +23 -13
- data/lib/celerity/elements/file_field.rb +17 -5
- data/lib/celerity/elements/form.rb +21 -16
- data/lib/celerity/elements/frame.rb +75 -53
- data/lib/celerity/elements/image.rb +76 -63
- data/lib/celerity/elements/label.rb +4 -2
- data/lib/celerity/elements/link.rb +30 -18
- data/lib/celerity/elements/meta.rb +6 -0
- data/lib/celerity/{non_control_elements.rb → elements/non_control_elements.rb} +106 -76
- data/lib/celerity/elements/option.rb +16 -2
- data/lib/celerity/elements/radio_check.rb +55 -20
- data/lib/celerity/elements/select_list.rb +65 -29
- data/lib/celerity/elements/table.rb +141 -94
- data/lib/celerity/elements/table_cell.rb +13 -6
- data/lib/celerity/elements/{table_body.rb → table_elements.rb} +20 -8
- data/lib/celerity/elements/table_row.rb +23 -7
- data/lib/celerity/elements/text_field.rb +89 -33
- data/lib/celerity/exception.rb +77 -41
- data/lib/celerity/extra/method_generator.rb +42 -24
- data/lib/celerity/htmlunit.rb +49 -0
- data/lib/celerity/htmlunit/commons-collections-3.2.1.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.5-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.5-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.12-20090308.130127-11.jar +0 -0
- data/lib/celerity/htmlunit/serializer-2.7.1.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.1.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.3.04.jar +0 -0
- data/lib/celerity/identifier.rb +3 -2
- data/lib/celerity/input_element.rb +5 -5
- data/lib/celerity/listener.rb +135 -0
- data/lib/celerity/resources/no_viewer.png +0 -0
- data/lib/celerity/util.rb +88 -0
- data/lib/celerity/version.rb +4 -3
- data/lib/celerity/watir_compatibility.rb +35 -25
- data/tasks/jar.rake +57 -0
- metadata +35 -142
- data.tar.gz.sig +0 -0
- data/Manifest.txt +0 -150
- data/lib/celerity/element_collections.rb +0 -54
- data/lib/celerity/element_map.rb +0 -51
- data/lib/celerity/elements/table_footer.rb +0 -30
- data/lib/celerity/elements/table_header.rb +0 -30
- data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
- data/lib/celerity/htmlunit/download.sh +0 -23
- 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.8.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
- data/spec/area_spec.rb +0 -97
- data/spec/areas_spec.rb +0 -40
- data/spec/browser_spec.rb +0 -266
- data/spec/button_spec.rb +0 -227
- data/spec/buttons_spec.rb +0 -39
- data/spec/checkbox_spec.rb +0 -302
- data/spec/checkboxes_spec.rb +0 -38
- data/spec/div_spec.rb +0 -207
- data/spec/divs_spec.rb +0 -39
- data/spec/element_spec.rb +0 -79
- data/spec/filefield_spec.rb +0 -123
- data/spec/filefields_spec.rb +0 -40
- data/spec/form_spec.rb +0 -59
- data/spec/forms_spec.rb +0 -41
- data/spec/frame_spec.rb +0 -121
- data/spec/frames_spec.rb +0 -71
- data/spec/hidden_spec.rb +0 -127
- data/spec/hiddens_spec.rb +0 -39
- data/spec/hn_spec.rb +0 -104
- data/spec/hns_spec.rb +0 -45
- data/spec/html/2000_spans.html +0 -2009
- data/spec/html/bug_duplicate_attributes.html +0 -14
- data/spec/html/bug_javascript_001.html +0 -11
- data/spec/html/form_js_bug.html +0 -11
- data/spec/html/forms_with_input_elements.html +0 -114
- data/spec/html/frame_1.html +0 -17
- data/spec/html/frame_2.html +0 -16
- data/spec/html/frames.html +0 -11
- data/spec/html/iframes.html +0 -12
- data/spec/html/images.html +0 -27
- 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/invalid_js.html +0 -11
- data/spec/html/latin1_text.html +0 -17
- data/spec/html/non_control_elements.html +0 -115
- data/spec/html/simple_ajax.html +0 -22
- data/spec/html/tables.html +0 -119
- data/spec/html/utf8_text.html +0 -15
- data/spec/htmlunit_spec.rb +0 -26
- data/spec/image_spec.rb +0 -220
- data/spec/images_spec.rb +0 -39
- data/spec/label_spec.rb +0 -79
- data/spec/labels_spec.rb +0 -40
- data/spec/li_spec.rb +0 -139
- data/spec/link_spec.rb +0 -189
- data/spec/links_spec.rb +0 -43
- data/spec/lis_spec.rb +0 -40
- data/spec/map_spec.rb +0 -102
- data/spec/maps_spec.rb +0 -40
- data/spec/meta_spec.rb +0 -8
- data/spec/ol_spec.rb +0 -87
- data/spec/ols_spec.rb +0 -40
- data/spec/option_spec.rb +0 -154
- data/spec/p_spec.rb +0 -171
- data/spec/pre_spec.rb +0 -135
- data/spec/pres_spec.rb +0 -40
- data/spec/ps_spec.rb +0 -40
- data/spec/radio_spec.rb +0 -299
- data/spec/radios_spec.rb +0 -42
- data/spec/select_list_spec.rb +0 -299
- data/spec/select_lists_spec.rb +0 -47
- data/spec/span_spec.rb +0 -184
- data/spec/spans_spec.rb +0 -64
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -55
- data/spec/table_bodies_spec.rb +0 -57
- data/spec/table_body_spec.rb +0 -111
- data/spec/table_cell_spec.rb +0 -74
- data/spec/table_cells_spec.rb +0 -59
- data/spec/table_footer_spec.rb +0 -101
- data/spec/table_footers_spec.rb +0 -55
- data/spec/table_header_spec.rb +0 -101
- data/spec/table_headers_spec.rb +0 -55
- data/spec/table_row_spec.rb +0 -104
- data/spec/table_rows_spec.rb +0 -58
- data/spec/table_spec.rb +0 -160
- data/spec/tables_spec.rb +0 -42
- data/spec/text_field_spec.rb +0 -323
- data/spec/text_fields_spec.rb +0 -44
- data/spec/ul_spec.rb +0 -88
- data/spec/uls_spec.rb +0 -40
- data/spec/watir_compatibility_spec.rb +0 -260
- data/support/spec_server.rb +0 -73
- data/tasks/rspec.rake +0 -30
- data/tasks/specserver.rake +0 -21
- metadata.gz.sig +0 -0
data/spec/checkboxes_spec.rb
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe "CheckBoxes" do
|
|
4
|
-
before :all do
|
|
5
|
-
@browser = Browser.new
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
before :each do
|
|
9
|
-
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#length" do
|
|
13
|
-
it "should return the number of checkboxes" do
|
|
14
|
-
@browser.checkboxes.length.should == 7
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe "#[]" do
|
|
19
|
-
it "should return the checkbox at the given index" do
|
|
20
|
-
@browser.checkboxes[1].id.should == "new_user_interests_books"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe "#each" do
|
|
25
|
-
it "should iterate through checkboxes correctly" do
|
|
26
|
-
@browser.checkboxes.each_with_index do |c, index|
|
|
27
|
-
c.name.should == @browser.checkbox(:index, index+1).name
|
|
28
|
-
c.id.should == @browser.checkbox(:index, index+1).id
|
|
29
|
-
c.value.should == @browser.checkbox(:index, index+1).value
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
after :all do
|
|
35
|
-
@browser.close
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
data/spec/div_spec.rb
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe "Div" do
|
|
4
|
-
|
|
5
|
-
before :all do
|
|
6
|
-
@browser = Browser.new
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
before :each do
|
|
10
|
-
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# Exists method
|
|
15
|
-
describe "#exists?" do
|
|
16
|
-
it "should return true if the element exists" do
|
|
17
|
-
@browser.div(:id, "header").should exist
|
|
18
|
-
@browser.div(:id, /header/).should exist
|
|
19
|
-
@browser.div(:title, "Header and primary navigation").should exist
|
|
20
|
-
@browser.div(:title, /Header and primary navigation/).should exist
|
|
21
|
-
@browser.div(:text, "This is a footer.").should exist
|
|
22
|
-
@browser.div(:text, /This is a footer\./).should exist
|
|
23
|
-
@browser.div(:class, "profile").should exist
|
|
24
|
-
@browser.div(:class, /profile/).should exist
|
|
25
|
-
@browser.div(:index, 1).should exist
|
|
26
|
-
@browser.div(:xpath, "//div[@id='header']").should exist
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should return true if the element exists (default how = :id)" do
|
|
30
|
-
@browser.div("header").should exist
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should return false if the element does not exist" do
|
|
34
|
-
@browser.div(:id, "no_such_id").should_not exist
|
|
35
|
-
@browser.div(:id, /no_such_id/).should_not exist
|
|
36
|
-
@browser.div(:title, "no_such_title").should_not exist
|
|
37
|
-
@browser.div(:title, /no_such_title/).should_not exist
|
|
38
|
-
@browser.div(:text, "no_such_text").should_not exist
|
|
39
|
-
@browser.div(:text, /no_such_text/).should_not exist
|
|
40
|
-
@browser.div(:class, "no_such_class").should_not exist
|
|
41
|
-
@browser.div(:class, /no_such_class/).should_not exist
|
|
42
|
-
@browser.div(:index, 1337).should_not exist
|
|
43
|
-
@browser.div(:xpath, "//div[@id='no_such_id']").should_not exist
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "should raise ArgumentError when 'what' argument is invalid" do
|
|
47
|
-
lambda { @browser.div(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
|
51
|
-
lambda { @browser.div(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Attribute methods
|
|
56
|
-
describe "#class_name" do
|
|
57
|
-
it "should return the class attribute if the element exists" do
|
|
58
|
-
@browser.div(:id , "footer").class_name.should == "profile"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "should return an empty string if the element exists but the attribute doesn't" do
|
|
62
|
-
@browser.div(:id , "content").class_name.should == ""
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it "should raise UnknownObjectException if the element does not exist" do
|
|
66
|
-
lambda { @browser.div(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
|
67
|
-
lambda { @browser.div(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
|
68
|
-
lambda { @browser.div(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
|
69
|
-
lambda { @browser.div(:xpath, "//div[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
describe "#id" do
|
|
74
|
-
it "should return the id attribute if the element exists" do
|
|
75
|
-
@browser.div(:index, 2).id.should == "outer_container"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "should return an empty string if the element exists, but the attribute doesn't" do
|
|
79
|
-
@browser.div(:index, 1).id.should == ""
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it "should raise UnknownObjectException if the element does not exist" do
|
|
83
|
-
lambda {@browser.div(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
|
84
|
-
lambda {@browser.div(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
|
85
|
-
lambda {@browser.div(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
describe "#name" do
|
|
90
|
-
it "should return the name attribute if the element exists" do
|
|
91
|
-
@browser.div(:id, 'promo').name.should == "invalid_attribute"
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it "should return an empty string if the element exists but the attribute doesn't" do
|
|
95
|
-
@browser.div(:index, 1).name.should == ""
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "should raise UnknownObjectException if the element does not exist" do
|
|
99
|
-
lambda {@browser.div(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
|
100
|
-
lambda {@browser.div(:title, "no_such_title").name }.should raise_error(UnknownObjectException)
|
|
101
|
-
lambda {@browser.div(:index, 1337).name }.should raise_error(UnknownObjectException)
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
describe "#style" do
|
|
106
|
-
it "should return the style attribute if the element exists" do
|
|
107
|
-
@browser.div(:id, 'best_language').style.should == "color: red; text-decoration: underline; cursor: pointer;"
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "should return an empty string if the element exists but the attribute doesn't" do
|
|
111
|
-
@browser.div(:id, 'promo').style.should == ""
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
it "should raise UnknownObjectException if the element does not exist" do
|
|
115
|
-
lambda {@browser.div(:id, "no_such_id").style }.should raise_error(UnknownObjectException)
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
describe "#text" do
|
|
120
|
-
it "should return the text of the div" do
|
|
121
|
-
@browser.div(:id, "footer").text.strip.should == "This is a footer."
|
|
122
|
-
@browser.div(:title, "Closing remarks").text.strip.should == "This is a footer."
|
|
123
|
-
@browser.div(:xpath, "//div[@id='footer']").text.strip.should == "This is a footer."
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it "should return an empty string if the element exists but contains no text" do
|
|
127
|
-
@browser.div(:index, 1).text.strip.should == ""
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "should raise UnknownObjectException if the element does not exist" do
|
|
131
|
-
lambda { @browser.div(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
|
132
|
-
lambda { @browser.div(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
|
133
|
-
lambda { @browser.div(:index, 1337).text }.should raise_error(UnknownObjectException)
|
|
134
|
-
lambda { @browser.div(:xpath, "//div[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
describe "#value" do
|
|
139
|
-
it "should return the value attribute if the element exists" do
|
|
140
|
-
@browser.div(:id, 'promo').value.should == "invalid_attribute"
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
it "should return an empty string if the element exists but the attribute doesn't" do
|
|
144
|
-
@browser.div(:index, 1).value.should == ""
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
it "should raise UnknownObjectException if the element does not exist" do
|
|
148
|
-
lambda {@browser.div(:id, "no_such_id").value }.should raise_error(UnknownObjectException)
|
|
149
|
-
lambda {@browser.div(:title, "no_such_title").value }.should raise_error(UnknownObjectException)
|
|
150
|
-
lambda {@browser.div(:index, 1337).value }.should raise_error(UnknownObjectException)
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
describe "#respond_to?" do
|
|
155
|
-
it "should return true for all attribute methods" do
|
|
156
|
-
@browser.div(:index, 1).should respond_to(:class_name)
|
|
157
|
-
@browser.div(:index, 1).should respond_to(:id)
|
|
158
|
-
@browser.div(:index, 1).should respond_to(:name)
|
|
159
|
-
@browser.div(:index, 1).should respond_to(:style)
|
|
160
|
-
@browser.div(:index, 1).should respond_to(:text)
|
|
161
|
-
@browser.div(:index, 1).should respond_to(:value)
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
# Manipulation methods
|
|
166
|
-
describe "#click" do
|
|
167
|
-
it "should fire events when clicked" do
|
|
168
|
-
@browser.div(:id, 'best_language').text.should_not == 'Ruby!'
|
|
169
|
-
@browser.div(:id, 'best_language').click
|
|
170
|
-
@browser.div(:id, 'best_language').text.should == 'Ruby!'
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
it "should raise UnknownObjectException if the element does not exist" do
|
|
174
|
-
lambda { @browser.div(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
|
175
|
-
lambda { @browser.div(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
|
176
|
-
lambda { @browser.div(:index, 1337).click }.should raise_error(UnknownObjectException)
|
|
177
|
-
lambda { @browser.div(:xpath, "//div[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
describe "#html" do
|
|
182
|
-
it "should return the HTML of the element" do
|
|
183
|
-
html = @browser.div(:id, 'footer').html
|
|
184
|
-
html.should include('<div id="footer" title="Closing remarks" class="profile">')
|
|
185
|
-
html.should include('This is a footer.')
|
|
186
|
-
html.should_not include('<div id="content">')
|
|
187
|
-
html.should_not include('</body>')
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
describe "#to_s" do
|
|
192
|
-
it "should return a human readable representation of the element" do
|
|
193
|
-
@browser.div(:id, 'footer').to_s.should ==
|
|
194
|
-
%q{tag: div
|
|
195
|
-
id: footer
|
|
196
|
-
title: Closing remarks
|
|
197
|
-
class: profile
|
|
198
|
-
text: This is a footer.}
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
after :all do
|
|
203
|
-
@browser.close
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
end
|
|
207
|
-
|
data/spec/divs_spec.rb
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe "Divs" do
|
|
4
|
-
before :all do
|
|
5
|
-
@browser = Browser.new
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
before :each do
|
|
9
|
-
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#length" do
|
|
13
|
-
it "should return the number of divs" do
|
|
14
|
-
@browser.divs.length.should == 8
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe "#[]" do
|
|
19
|
-
it "should return the div at the given index" do
|
|
20
|
-
@browser.divs[2].id.should == "outer_container"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe "#each" do
|
|
25
|
-
it "should iterate through divs correctly" do
|
|
26
|
-
@browser.divs.each_with_index do |d, index|
|
|
27
|
-
d.name.should == @browser.div(:index, index+1).name
|
|
28
|
-
d.id.should == @browser.div(:index, index+1).id
|
|
29
|
-
d.class_name.should == @browser.div(:index, index+1).class_name
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
after :all do
|
|
35
|
-
@browser.close
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
|
data/spec/element_spec.rb
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe "Element" do
|
|
4
|
-
|
|
5
|
-
before :all do
|
|
6
|
-
@browser = Browser.new
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
before :each do
|
|
10
|
-
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe "::new" do
|
|
14
|
-
it "should find elements matching the conditions when given a hash of :how => 'what' arguments" do
|
|
15
|
-
@browser.checkbox(:name => 'new_user_interests', :title => 'Dancing is fun!').value.should == 'dancing'
|
|
16
|
-
@browser.text_field(:class_name => 'name', :index => 2).id.should == 'new_user_last_name'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "should raise UnknownObjectException with a sane error message when given a hash of :how => 'what' arguments (non-existing object)" do
|
|
20
|
-
conditions = {:index => 100, :name => "foo"}
|
|
21
|
-
lambda { @browser.text_field(conditions).id }.should raise_error(UnknownObjectException, /Unable to locate object, using (\{:name=>"foo", :index=>100\}|\{:index=>100, :name=>"foo"\})/)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "should raise ArgumentError if given the wrong number of arguments" do
|
|
25
|
-
container = mock("container", :null_object => true)
|
|
26
|
-
lambda { Element.new(container, 1,2,3,4) }.should raise_error(ArgumentError, "wrong number of arguments (4 for 2)")
|
|
27
|
-
lambda { Element.new(container, "foo") }.should raise_error(ArgumentError, "wrong number of arguments (1 for 2)")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe "#focus" do
|
|
33
|
-
it "should fire the onfocus event for the given element" do
|
|
34
|
-
tf = @browser.text_field(:id, "new_user_occupation")
|
|
35
|
-
tf.value.should == "Developer"
|
|
36
|
-
tf.focus
|
|
37
|
-
@browser.div(:id, "onfocus_test").text.should == "changed by onfocus event"
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe "#parent" do
|
|
42
|
-
it "should get the parent of this element" do
|
|
43
|
-
@browser.text_field(:id, "new_user_email").parent.should be_instance_of(Form)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe "#method_missing" do
|
|
48
|
-
it "should magically return the requested attribute if the attribute is defined in the attribute list" do
|
|
49
|
-
@browser.form(:index, 1).action.should == 'post_to_me'
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "should raise NoMethodError if the requested method isn't among the attributes" do
|
|
53
|
-
lambda { @browser.button(:index, 1).no_such_attribute_or_method }.should raise_error(NoMethodError)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
describe "#html" do
|
|
58
|
-
it "should return the descriptive (actual) html for the image element" do
|
|
59
|
-
@browser.goto(TEST_HOST + "/images.html")
|
|
60
|
-
@browser.image(:id, 'non_self_closing').html.chomp.should == '<img src="images/1.gif" alt="1" id="non_self_closing"></img>'
|
|
61
|
-
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
|
62
|
-
@browser.div(:id, 'html_test').html.chomp.should ==
|
|
63
|
-
'<div id="html_test" class=some_class title = "This is a title">
|
|
64
|
-
asdf
|
|
65
|
-
</div>' #TODO: This expected value might be a little off, whitespace-wise
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe "#text" do
|
|
70
|
-
it "should return a text representation including newlines" do
|
|
71
|
-
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
72
|
-
@browser.form(:id, "delete_user").text.should == "Username Username 1 Username 2 Username 3 \nComment Default comment."
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
after :all do
|
|
77
|
-
@browser.close
|
|
78
|
-
end
|
|
79
|
-
end
|
data/spec/filefield_spec.rb
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe "FileField" do
|
|
4
|
-
before :all do
|
|
5
|
-
@browser = Browser.new
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
before :each do
|
|
9
|
-
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#exist?" do
|
|
13
|
-
it "should return 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 "should return true if the element exists (default how = :name)" do
|
|
25
|
-
@browser.file_field("new_user_portrait").should exist
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should return 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 "should raise ArgumentError when 'what' argument is invalid" do
|
|
40
|
-
lambda { @browser.file_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should raise 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 "should return the class attribute if the text field exists" do
|
|
52
|
-
@browser.file_field(:index, 1).class_name.should == "portrait"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should raise 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 "should return 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 "should raise 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 "should return 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 "should raise 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 "should return 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 "should return the type attribute if the text field exists" do
|
|
88
|
-
@browser.file_field(:index, 1).type.should == "file"
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "should raise 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 "should return 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 "should be able to set a file path in the field and click the upload button and fire the onchange event" do
|
|
111
|
-
@browser.file_field(:name, "new_user_portrait").set(__FILE__)
|
|
112
|
-
@browser.file_field(:name, "new_user_portrait").value.should == __FILE__
|
|
113
|
-
@browser.div(:id, 'changed_language').text.should == "File onchange triggered"
|
|
114
|
-
@browser.button(:name, "new_user_submit").click
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
after :all do
|
|
119
|
-
@browser.close
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
end
|
|
123
|
-
|