celerity 0.0.1
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 +4 -0
- data/License.txt +621 -0
- data/README.txt +58 -0
- data/Rakefile +4 -0
- data/lib/celerity.rb +47 -0
- data/lib/celerity/clickable_element.rb +11 -0
- data/lib/celerity/collections.rb +99 -0
- data/lib/celerity/container.rb +369 -0
- data/lib/celerity/disabled_element.rb +20 -0
- data/lib/celerity/element.rb +114 -0
- data/lib/celerity/element_collections.rb +67 -0
- data/lib/celerity/elements/button.rb +13 -0
- data/lib/celerity/elements/file_field.rb +12 -0
- data/lib/celerity/elements/form.rb +15 -0
- data/lib/celerity/elements/frame.rb +44 -0
- data/lib/celerity/elements/image.rb +70 -0
- data/lib/celerity/elements/label.rb +10 -0
- data/lib/celerity/elements/link.rb +13 -0
- data/lib/celerity/elements/radio_check.rb +59 -0
- data/lib/celerity/elements/select_list.rb +84 -0
- data/lib/celerity/elements/table.rb +94 -0
- data/lib/celerity/elements/table_body.rb +38 -0
- data/lib/celerity/elements/table_cell.rb +30 -0
- data/lib/celerity/elements/table_row.rb +34 -0
- data/lib/celerity/elements/text_field.rb +80 -0
- data/lib/celerity/exception.rb +48 -0
- data/lib/celerity/htmlunit/commons-codec-1.3.jar +0 -0
- data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
- data/lib/celerity/htmlunit/commons-httpclient-3.1.jar +0 -0
- data/lib/celerity/htmlunit/commons-io-1.4.jar +0 -0
- data/lib/celerity/htmlunit/commons-lang-2.4.jar +0 -0
- data/lib/celerity/htmlunit/commons-logging-1.1.1.jar +0 -0
- data/lib/celerity/htmlunit/cssparser-0.9.5.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.7.jar +0 -0
- data/lib/celerity/htmlunit/sac-1.3.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
- data/lib/celerity/htmlunit/xercesImpl-2.8.1.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
- data/lib/celerity/ie.rb +126 -0
- data/lib/celerity/input_element.rb +29 -0
- data/lib/celerity/non_control_elements.rb +50 -0
- data/lib/celerity/version.rb +9 -0
- data/setup.rb +1585 -0
- data/spec/area_spec.rb +79 -0
- data/spec/areas_spec.rb +41 -0
- data/spec/button_spec.rb +171 -0
- data/spec/buttons_spec.rb +40 -0
- data/spec/checkbox_spec.rb +259 -0
- data/spec/checkboxes_spec.rb +39 -0
- data/spec/div_spec.rb +174 -0
- data/spec/divs_spec.rb +40 -0
- data/spec/element_spec.rb +29 -0
- data/spec/filefield_spec.rb +110 -0
- data/spec/filefields_spec.rb +41 -0
- data/spec/form_spec.rb +53 -0
- data/spec/forms_spec.rb +42 -0
- data/spec/frame_spec.rb +103 -0
- data/spec/hidden_spec.rb +105 -0
- data/spec/hiddens_spec.rb +40 -0
- data/spec/html/forms_with_input_elements.html +107 -0
- data/spec/html/frame_1.html +17 -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 +24 -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/non_control_elements.html +85 -0
- data/spec/html/tables.html +119 -0
- data/spec/ie_spec.rb +146 -0
- data/spec/image_spec.rb +210 -0
- data/spec/images_spec.rb +39 -0
- data/spec/label_spec.rb +65 -0
- data/spec/labels_spec.rb +41 -0
- data/spec/li_spec.rb +114 -0
- data/spec/link_spec.rb +147 -0
- data/spec/links_spec.rb +43 -0
- data/spec/lis_spec.rb +40 -0
- data/spec/map_spec.rb +83 -0
- data/spec/maps_spec.rb +41 -0
- data/spec/p_spec.rb +140 -0
- data/spec/pre_spec.rb +110 -0
- data/spec/pres_spec.rb +41 -0
- data/spec/ps_spec.rb +40 -0
- data/spec/radio_spec.rb +260 -0
- data/spec/radios_spec.rb +43 -0
- data/spec/select_list_spec.rb +286 -0
- data/spec/select_lists_spec.rb +47 -0
- data/spec/span_spec.rb +156 -0
- data/spec/spans_spec.rb +65 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +90 -0
- data/spec/table_bodies.rb +40 -0
- data/spec/table_bodies_spec.rb +42 -0
- data/spec/table_body_spec.rb +72 -0
- data/spec/table_cell_spec.rb +61 -0
- data/spec/table_cells_spec.rb +60 -0
- data/spec/table_row_spec.rb +59 -0
- data/spec/table_rows_spec.rb +57 -0
- data/spec/table_spec.rb +111 -0
- data/spec/tables_spec.rb +42 -0
- data/spec/text_field_spec.rb +234 -0
- data/spec/text_fields_spec.rb +45 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +23 -0
- data/tasks/simple_ci.rake +94 -0
- data/tasks/testserver.rake +17 -0
- metadata +174 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "CheckBoxes" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#length" do
|
|
14
|
+
it "should return the number of checkboxes" do
|
|
15
|
+
@ie.checkboxes.length.should == 6
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "#[]" do
|
|
20
|
+
it "should return the checkbox at the given index" do
|
|
21
|
+
@ie.checkboxes[1].id.should == "new_user_interests_books"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "#each" do
|
|
26
|
+
it "should iterate through checkboxes correctly" do
|
|
27
|
+
@ie.checkboxes.each_with_index do |c, index|
|
|
28
|
+
c.name.should == @ie.checkbox(:index, index+1).name
|
|
29
|
+
c.id.should == @ie.checkbox(:index, index+1).id
|
|
30
|
+
c.value.should == @ie.checkbox(:index, index+1).value
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
after :all do
|
|
36
|
+
@ie.close
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
data/spec/div_spec.rb
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Div" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.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
|
+
@ie.div(:id, "header").should exist
|
|
18
|
+
@ie.div(:id, /header/).should exist
|
|
19
|
+
@ie.div(:title, "Header and primary navigation").should exist
|
|
20
|
+
@ie.div(:title, /Header and primary navigation/).should exist
|
|
21
|
+
@ie.div(:text, "This is a footer.").should exist
|
|
22
|
+
@ie.div(:text, /This is a footer\./).should exist
|
|
23
|
+
@ie.div(:class, "profile").should exist
|
|
24
|
+
@ie.div(:class, /profile/).should exist
|
|
25
|
+
@ie.div(:index, 1).should exist
|
|
26
|
+
@ie.div(:xpath, "//div[@id='header']").should exist
|
|
27
|
+
end
|
|
28
|
+
it "should return false if the element does not exist" do
|
|
29
|
+
@ie.div(:id, "no_such_id").should_not exist
|
|
30
|
+
@ie.div(:id, /no_such_id/).should_not exist
|
|
31
|
+
@ie.div(:title, "no_such_title").should_not exist
|
|
32
|
+
@ie.div(:title, /no_such_title/).should_not exist
|
|
33
|
+
@ie.div(:text, "no_such_text").should_not exist
|
|
34
|
+
@ie.div(:text, /no_such_text/).should_not exist
|
|
35
|
+
@ie.div(:class, "no_such_class").should_not exist
|
|
36
|
+
@ie.div(:class, /no_such_class/).should_not exist
|
|
37
|
+
@ie.div(:index, 1337).should_not exist
|
|
38
|
+
@ie.div(:xpath, "//div[@id='no_such_id']").should_not exist
|
|
39
|
+
end
|
|
40
|
+
it "should raise ArgumentError when what argument is invalid" do
|
|
41
|
+
lambda { @ie.div(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
42
|
+
end
|
|
43
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
44
|
+
lambda { @ie.div(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Attribute methods
|
|
49
|
+
describe "#class_name" do
|
|
50
|
+
it "should return the class attribute if the element exists" do
|
|
51
|
+
@ie.div(:id , "footer").class_name.should == "profile"
|
|
52
|
+
end
|
|
53
|
+
it "should return an empty string if the element exists but the attribute doesn't" do
|
|
54
|
+
@ie.div(:id , "content").class_name.should == ""
|
|
55
|
+
end
|
|
56
|
+
it "should raise UnknownObjectException if the element does not exist" do
|
|
57
|
+
lambda { @ie.div(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
|
58
|
+
lambda { @ie.div(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
|
59
|
+
lambda { @ie.div(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
|
60
|
+
lambda { @ie.div(:xpath, "//div[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "#id" do
|
|
65
|
+
it "should return the id attribute if the element exists" do
|
|
66
|
+
@ie.div(:index, 2).id.should == "outer_container"
|
|
67
|
+
end
|
|
68
|
+
it "should return an empty string if the element exists, but the attribute doesn't" do
|
|
69
|
+
@ie.div(:index, 1).id.should == ""
|
|
70
|
+
end
|
|
71
|
+
it "should raise UnknownObjectException if the element does not exist" do
|
|
72
|
+
lambda {@ie.div(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
|
73
|
+
lambda {@ie.div(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
|
74
|
+
lambda {@ie.div(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe "#name" do
|
|
79
|
+
it "should return the name attribute if the element exists" do
|
|
80
|
+
@ie.div(:id, 'promo').name.should == "invalid_attribute"
|
|
81
|
+
end
|
|
82
|
+
it "should return an empty string if the element exists but the attribute doesn't" do
|
|
83
|
+
@ie.div(:index, 1).name.should == ""
|
|
84
|
+
end
|
|
85
|
+
it "should raise UnknownObjectException if the element does not exist" do
|
|
86
|
+
lambda {@ie.div(:id, "div77").name }.should raise_error(UnknownObjectException)
|
|
87
|
+
lambda {@ie.div(:title, "div77").name }.should raise_error(UnknownObjectException)
|
|
88
|
+
lambda {@ie.div(:index, 44).name }.should raise_error(UnknownObjectException)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe "#text" do
|
|
93
|
+
it "should return the text of the div" do
|
|
94
|
+
@ie.div(:id, "footer").text.strip.should == "This is a footer."
|
|
95
|
+
@ie.div(:title, "Closing remarks").text.strip.should == "This is a footer."
|
|
96
|
+
@ie.div(:xpath, "//div[@id='footer']").text.strip.should == "This is a footer."
|
|
97
|
+
end
|
|
98
|
+
it "should return an empty string if the element exists but contains no text" do
|
|
99
|
+
@ie.div(:index, 1).text.strip.should == ""
|
|
100
|
+
end
|
|
101
|
+
it "should raise UnknownObjectException if the element does not exist" do
|
|
102
|
+
lambda { @ie.div(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
|
103
|
+
lambda { @ie.div(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
|
104
|
+
lambda { @ie.div(:index, 1337).text }.should raise_error(UnknownObjectException)
|
|
105
|
+
lambda { @ie.div(:xpath, "//div[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
describe "#value" do
|
|
110
|
+
it "should return the value attribute if the element exists" do
|
|
111
|
+
@ie.div(:id, 'promo').value.should == "invalid_attribute"
|
|
112
|
+
end
|
|
113
|
+
it "should return an empty string if the element exists but the attribute doesn't" do
|
|
114
|
+
@ie.div(:index, 1).value.should == ""
|
|
115
|
+
end
|
|
116
|
+
it "should raise UnknownObjectException if the element does not exist" do
|
|
117
|
+
lambda {@ie.div(:id, "no_such_id").value }.should raise_error(UnknownObjectException)
|
|
118
|
+
lambda {@ie.div(:title, "no_such_title").value }.should raise_error(UnknownObjectException)
|
|
119
|
+
lambda {@ie.div(:index, 1337).value }.should raise_error(UnknownObjectException)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Manipulation methods
|
|
124
|
+
describe "#click" do
|
|
125
|
+
it "should fire events when clicked"
|
|
126
|
+
it "should raise UnknownObjectException if the element does not exist" do
|
|
127
|
+
lambda { @ie.div(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
|
128
|
+
lambda { @ie.div(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
|
129
|
+
lambda { @ie.div(:index, 1337).click }.should raise_error(UnknownObjectException)
|
|
130
|
+
lambda { @ie.div(:xpath, "//div[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe "#html" do
|
|
135
|
+
it "should return the HTML of the element" do
|
|
136
|
+
html = @ie.div(:id, 'footer').html
|
|
137
|
+
html.should include('<div id="footer" title="Closing remarks" class="profile">')
|
|
138
|
+
html.should include('<span class="footer">This is a footer.</span>')
|
|
139
|
+
html.should_not include('<div id="content">')
|
|
140
|
+
html.should_not include('</body>')
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
describe "#to_s" do
|
|
145
|
+
it "should return a human readable representation of the element" do
|
|
146
|
+
@ie.div(:id, 'footer').to_s.should == "tag: div\n" +
|
|
147
|
+
" id: footer\n" +
|
|
148
|
+
" title: Closing remarks\n" +
|
|
149
|
+
" class: profile\n" +
|
|
150
|
+
" text: This is a footer."
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Divs can't be disabled
|
|
155
|
+
# describe "#disabled?" do
|
|
156
|
+
# it "should raise UnknownObjectException if the element does not exist" do
|
|
157
|
+
# lambda {@ie.div(:id , "div77").disabled? }.should raise_error(UnknownObjectException)
|
|
158
|
+
# lambda {@ie.div(:title , "div77").disabled? }.should raise_error(UnknownObjectException)
|
|
159
|
+
# lambda {@ie.div(:index , 44).disabled? }.should raise_error(UnknownObjectException)
|
|
160
|
+
# end
|
|
161
|
+
#
|
|
162
|
+
# it "should return false if the element is enabled" do
|
|
163
|
+
# @ie.div(:index , 2).should_not be_disabled
|
|
164
|
+
# end
|
|
165
|
+
#
|
|
166
|
+
# it "should return true if the element is disabled"
|
|
167
|
+
# end
|
|
168
|
+
|
|
169
|
+
after :all do
|
|
170
|
+
@ie.close
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
end
|
|
174
|
+
|
data/spec/divs_spec.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Divs" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.goto(TEST_HOST + "/non_control_elements.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#length" do
|
|
14
|
+
it "should return the number of divs" do
|
|
15
|
+
@ie.divs.length.should == 6
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "#[]" do
|
|
20
|
+
it "should return the div at the given index" do
|
|
21
|
+
@ie.divs[2].id.should == "outer_container"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "#each" do
|
|
26
|
+
it "should iterate through divs correctly" do
|
|
27
|
+
@ie.divs.each_with_index do |d, index|
|
|
28
|
+
d.name.should == @ie.div(:index, index+1).name
|
|
29
|
+
d.id.should == @ie.div(:index, index+1).id
|
|
30
|
+
d.class_name.should == @ie.div(:index, index+1).class_name
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
after :all do
|
|
36
|
+
@ie.close
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Element" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#method_missing" do
|
|
15
|
+
it "should magically return the requested attribute if the attribute is defined in the attribute list" do
|
|
16
|
+
@ie.form(:index, 1).action.should == 'forms_with_input_elements.html'
|
|
17
|
+
end
|
|
18
|
+
it "should call the super class method if the attribute is not defined in the element's attribute list" do
|
|
19
|
+
@ie.form(:index, 2).text.should == 'Username Username 1 Delete'
|
|
20
|
+
end
|
|
21
|
+
it "should raise NoMethodError if the requested method is not defined in the super class" do
|
|
22
|
+
lambda { @ie.button(:index, 1).no_such_attribute_or_method }.should raise_error(NoMethodError)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
after :all do
|
|
27
|
+
@ie.close
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "FileField" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Exist method
|
|
15
|
+
|
|
16
|
+
describe "#exist?" do
|
|
17
|
+
it "should return true if the file field exists" do
|
|
18
|
+
@ie.file_field(:id, 'new_user_portrait').should exist
|
|
19
|
+
@ie.file_field(:id, /new_user_portrait/).should exist
|
|
20
|
+
@ie.file_field(:name, 'new_user_portrait').should exist
|
|
21
|
+
@ie.file_field(:name, /new_user_portrait/).should exist
|
|
22
|
+
@ie.file_field(:class, 'portrait').should exist
|
|
23
|
+
@ie.file_field(:class, /portrait/).should exist
|
|
24
|
+
@ie.file_field(:index, 1).should exist
|
|
25
|
+
@ie.file_field(:xpath, "//input[@id='new_user_portrait']").should exist
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should return false if the file field doesn't exist" do
|
|
29
|
+
@ie.file_field(:id, 'no_such_id').should_not exist
|
|
30
|
+
@ie.file_field(:id, /no_such_id/).should_not exist
|
|
31
|
+
@ie.file_field(:name, 'no_such_name').should_not exist
|
|
32
|
+
@ie.file_field(:name, /no_such_name/).should_not exist
|
|
33
|
+
@ie.file_field(:class, 'no_such_class').should_not exist
|
|
34
|
+
@ie.file_field(:class, /no_such_class/).should_not exist
|
|
35
|
+
@ie.file_field(:index, 1337).should_not exist
|
|
36
|
+
@ie.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 { @ie.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 { @ie.file_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Attribute methods
|
|
50
|
+
|
|
51
|
+
describe "#class_name" do
|
|
52
|
+
it "should return the class attribute if the text field exists" do
|
|
53
|
+
@ie.file_field(:index, 1).class_name.should == "portrait"
|
|
54
|
+
end
|
|
55
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
56
|
+
lambda { @ie.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
|
+
@ie.file_field(:index, 1).id.should == "new_user_portrait"
|
|
63
|
+
end
|
|
64
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
65
|
+
lambda { @ie.file_field(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe "#name" do
|
|
70
|
+
it "should return the name attribute if the text field exists" do
|
|
71
|
+
@ie.file_field(:index, 1).name.should == "new_user_portrait"
|
|
72
|
+
end
|
|
73
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
74
|
+
lambda { @ie.file_field(:index, 1337).name }.should raise_error(UnknownObjectException)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe "#title" do
|
|
79
|
+
it "should return the title attribute if the text field exists" do
|
|
80
|
+
@ie.file_field(:id, "new_user_portrait").title.should == "Smile!"
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe "#type" do
|
|
85
|
+
it "should return the type attribute if the text field exists" do
|
|
86
|
+
@ie.file_field(:index, 1).type.should == "file"
|
|
87
|
+
end
|
|
88
|
+
it "should raise UnknownObjectException if the text field doesn't exist" do
|
|
89
|
+
lambda { @ie.file_field(:index, 1337).type }.should raise_error(UnknownObjectException)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# Manipulation methods
|
|
95
|
+
|
|
96
|
+
describe "#set" do
|
|
97
|
+
it "should be able to set a file path in the field and click the upload button" do
|
|
98
|
+
@ie.file_field(:name, "new_user_portrait").set(__FILE__)
|
|
99
|
+
@ie.file_field(:name, "new_user_portrait").value.should == __FILE__
|
|
100
|
+
# @ie.button(:name, "new_user_submit").click
|
|
101
|
+
pending
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
after :all do
|
|
106
|
+
@ie.close
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "FileFields" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#length" do
|
|
15
|
+
it "should return the correct number of file fields" do
|
|
16
|
+
@ie.file_fields.length.should == 2
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe "#[]" do
|
|
21
|
+
it "should return the file field at the given index" do
|
|
22
|
+
@ie.file_fields[1].id.should == "new_user_portrait"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "#each" do
|
|
27
|
+
it "should iterate through file fields correctly" do
|
|
28
|
+
@ie.file_fields.each_with_index do |f, index|
|
|
29
|
+
f.name.should == @ie.file_field(:index, index+1).name
|
|
30
|
+
f.id.should == @ie.file_field(:index, index+1).id
|
|
31
|
+
f.value.should == @ie.file_field(:index, index+1).value
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
after :all do
|
|
37
|
+
@ie.close
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
data/spec/form_spec.rb
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Form" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#exists" do
|
|
14
|
+
it "should return true if the form exists" do
|
|
15
|
+
@ie.form(:id, 'new_user').should exist
|
|
16
|
+
@ie.form(:id, /new_user/).should exist
|
|
17
|
+
@ie.form(:class, 'user').should exist
|
|
18
|
+
@ie.form(:class, /user/).should exist
|
|
19
|
+
@ie.form(:method, 'post').should exist
|
|
20
|
+
@ie.form(:method, /post/).should exist
|
|
21
|
+
@ie.form(:action, 'forms_with_input_elements.html').should exist
|
|
22
|
+
@ie.form(:action, /forms_with_input_elements.html/).should exist
|
|
23
|
+
@ie.form(:index, 1).should exist
|
|
24
|
+
@ie.form(:xpath, "//form[@id='new_user']").should exist
|
|
25
|
+
end
|
|
26
|
+
it "should return false if the form doesn't exist" do
|
|
27
|
+
@ie.form(:id, 'no_such_id').should_not exist
|
|
28
|
+
@ie.form(:id, /no_such_id/).should_not exist
|
|
29
|
+
@ie.form(:class, 'no_such_class').should_not exist
|
|
30
|
+
@ie.form(:class, /no_such_class/).should_not exist
|
|
31
|
+
@ie.form(:method, 'no_such_method').should_not exist
|
|
32
|
+
@ie.form(:method, /no_such_method/).should_not exist
|
|
33
|
+
@ie.form(:action, 'no_such_action').should_not exist
|
|
34
|
+
@ie.form(:action, /no_such_action/).should_not exist
|
|
35
|
+
@ie.form(:index, 1337).should_not exist
|
|
36
|
+
@ie.form(:xpath, "//form[@id='no_such_id']").should_not exist
|
|
37
|
+
end
|
|
38
|
+
it "should raise ArgumentError when what argument is invalid" do
|
|
39
|
+
lambda { @ie.form(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
40
|
+
end
|
|
41
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
42
|
+
lambda { @ie.form(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "#submit" do
|
|
47
|
+
it "should submit the form" do
|
|
48
|
+
@ie.form(:id, "delete_user").submit
|
|
49
|
+
@ie.text.should include("Semantic table")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|