operawatir 0.3-jruby
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/.gitmodules +3 -0
- data/.yardopts +5 -0
- data/AUTHORS +7 -0
- data/Gemfile +9 -0
- data/LICENSE +30 -0
- data/README.md +158 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/bin/desktopwatir +106 -0
- data/bin/operawatir +95 -0
- data/lib/operadriver/APACHE_2.0_LICENSE.txt +204 -0
- data/lib/operadriver/NEW_BSD_LICENSE.txt +36 -0
- data/lib/operadriver/commons-jxpath-1.3.jar +0 -0
- data/lib/operadriver/protobuf-java-2.3.0.jar +0 -0
- data/lib/operadriver/selenium-common.jar +0 -0
- data/lib/operadriver/webdriver-opera.jar +0 -0
- data/lib/operawatir.rb +46 -0
- data/lib/operawatir/browser.rb +181 -0
- data/lib/operawatir/collection.rb +133 -0
- data/lib/operawatir/compat.rb +25 -0
- data/lib/operawatir/compat/browser.rb +20 -0
- data/lib/operawatir/compat/collection.rb +99 -0
- data/lib/operawatir/compat/deprecation.rb +46 -0
- data/lib/operawatir/compat/element.rb +165 -0
- data/lib/operawatir/compat/element_finders.rb +159 -0
- data/lib/operawatir/compat/window.rb +27 -0
- data/lib/operawatir/element.rb +228 -0
- data/lib/operawatir/exceptions.rb +38 -0
- data/lib/operawatir/helper.rb +53 -0
- data/lib/operawatir/selector.rb +111 -0
- data/lib/operawatir/version.rb +15 -0
- data/lib/operawatir/window.rb +174 -0
- data/spec/fire_event/fire_event.rb +268 -0
- data/spec/fire_event/interactive/onBlur.html +45 -0
- data/spec/fire_event/interactive/onChange.html +47 -0
- data/spec/fire_event/interactive/onClick.html +45 -0
- data/spec/fire_event/interactive/onDblClick.html +45 -0
- data/spec/fire_event/interactive/onFocus.html +45 -0
- data/spec/fire_event/interactive/onMouseDown.html +45 -0
- data/spec/fire_event/interactive/onMouseMove.html +45 -0
- data/spec/fire_event/interactive/onMouseOut.html +45 -0
- data/spec/fire_event/interactive/onMouseOver.html +45 -0
- data/spec/fire_event/interactive/onMouseUp.html +45 -0
- data/spec/fire_event/interactive/onScroll.html +14 -0
- data/spec/legacy_watirspec/area_spec.rb +106 -0
- data/spec/legacy_watirspec/areas_spec.rb +38 -0
- data/spec/legacy_watirspec/browser_spec.rb +297 -0
- data/spec/legacy_watirspec/button_spec.rb +260 -0
- data/spec/legacy_watirspec/buttons_spec.rb +54 -0
- data/spec/legacy_watirspec/checkbox_spec.rb +280 -0
- data/spec/legacy_watirspec/checkboxes_spec.rb +38 -0
- data/spec/legacy_watirspec/collections_spec.rb +18 -0
- data/spec/legacy_watirspec/dd_spec.rb +140 -0
- data/spec/legacy_watirspec/dds_spec.rb +38 -0
- data/spec/legacy_watirspec/del_spec.rb +181 -0
- data/spec/legacy_watirspec/dels_spec.rb +62 -0
- data/spec/legacy_watirspec/div_spec.rb +244 -0
- data/spec/legacy_watirspec/divs_spec.rb +38 -0
- data/spec/legacy_watirspec/dl_spec.rb +140 -0
- data/spec/legacy_watirspec/dls_spec.rb +38 -0
- data/spec/legacy_watirspec/dt_spec.rb +140 -0
- data/spec/legacy_watirspec/dts_spec.rb +38 -0
- data/spec/legacy_watirspec/element_spec.rb +86 -0
- data/spec/legacy_watirspec/em_spec.rb +114 -0
- data/spec/legacy_watirspec/ems_spec.rb +38 -0
- data/spec/legacy_watirspec/filefield_spec.rb +127 -0
- data/spec/legacy_watirspec/filefields_spec.rb +38 -0
- data/spec/legacy_watirspec/fixtures/2000_spans.html +2009 -0
- data/spec/legacy_watirspec/fixtures/bug_duplicate_attributes.html +14 -0
- data/spec/legacy_watirspec/fixtures/bug_javascript_001.html +11 -0
- data/spec/legacy_watirspec/fixtures/buttons_with_duplicate_ids.html +18 -0
- data/spec/legacy_watirspec/fixtures/collections.html +15 -0
- data/spec/legacy_watirspec/fixtures/definition_lists.html +48 -0
- data/spec/legacy_watirspec/fixtures/euc-jp_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/forms_with_input_elements.html +126 -0
- data/spec/legacy_watirspec/fixtures/frame_1.html +18 -0
- data/spec/legacy_watirspec/fixtures/frame_2.html +16 -0
- data/spec/legacy_watirspec/fixtures/frames.html +11 -0
- data/spec/legacy_watirspec/fixtures/iframes.html +12 -0
- data/spec/legacy_watirspec/fixtures/images.html +27 -0
- data/spec/legacy_watirspec/fixtures/images/1.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/2.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/3.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/button.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/circle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/map.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/map2.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/minus.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/originaltriangle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/plus.gif +0 -0
- data/spec/legacy_watirspec/fixtures/images/square.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/images/triangle.jpg +0 -0
- data/spec/legacy_watirspec/fixtures/iso-2022-jp_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/javascript/helpers.js +16 -0
- data/spec/legacy_watirspec/fixtures/jquery.html +28 -0
- data/spec/legacy_watirspec/fixtures/latin1_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/multiple_ids.html +14 -0
- data/spec/legacy_watirspec/fixtures/non_control_elements.html +135 -0
- data/spec/legacy_watirspec/fixtures/parser_bug_001.html +12 -0
- data/spec/legacy_watirspec/fixtures/prevent_form_submit.html +20 -0
- data/spec/legacy_watirspec/fixtures/right_click.html +11 -0
- data/spec/legacy_watirspec/fixtures/shift_jis_text.html +17 -0
- data/spec/legacy_watirspec/fixtures/tables.html +121 -0
- data/spec/legacy_watirspec/fixtures/timeout.html +16 -0
- data/spec/legacy_watirspec/fixtures/timeout_window_location.html +19 -0
- data/spec/legacy_watirspec/fixtures/tiny_mce.html +27 -0
- data/spec/legacy_watirspec/fixtures/utf8_text.html +15 -0
- data/spec/legacy_watirspec/fixtures/watirspec.css +0 -0
- data/spec/legacy_watirspec/form_spec.rb +73 -0
- data/spec/legacy_watirspec/forms_spec.rb +39 -0
- data/spec/legacy_watirspec/frame_spec.rb +161 -0
- data/spec/legacy_watirspec/frames_spec.rb +75 -0
- data/spec/legacy_watirspec/guards.rb +38 -0
- data/spec/legacy_watirspec/hidden_spec.rb +120 -0
- data/spec/legacy_watirspec/hiddens_spec.rb +38 -0
- data/spec/legacy_watirspec/hn_spec.rb +101 -0
- data/spec/legacy_watirspec/hns_spec.rb +39 -0
- data/spec/legacy_watirspec/image_spec.rb +237 -0
- data/spec/legacy_watirspec/images_spec.rb +38 -0
- data/spec/legacy_watirspec/ins_spec.rb +181 -0
- data/spec/legacy_watirspec/inses_spec.rb +62 -0
- data/spec/legacy_watirspec/label_spec.rb +85 -0
- data/spec/legacy_watirspec/labels_spec.rb +38 -0
- data/spec/legacy_watirspec/li_spec.rb +135 -0
- data/spec/legacy_watirspec/link_spec.rb +194 -0
- data/spec/legacy_watirspec/links_spec.rb +39 -0
- data/spec/legacy_watirspec/lis_spec.rb +38 -0
- data/spec/legacy_watirspec/map_spec.rb +100 -0
- data/spec/legacy_watirspec/maps_spec.rb +38 -0
- data/spec/legacy_watirspec/meta_spec.rb +26 -0
- data/spec/legacy_watirspec/metas_spec.rb +36 -0
- data/spec/legacy_watirspec/ol_spec.rb +86 -0
- data/spec/legacy_watirspec/ols_spec.rb +38 -0
- data/spec/legacy_watirspec/option_spec.rb +187 -0
- data/spec/legacy_watirspec/p_spec.rb +167 -0
- data/spec/legacy_watirspec/pre_spec.rb +133 -0
- data/spec/legacy_watirspec/pres_spec.rb +38 -0
- data/spec/legacy_watirspec/ps_spec.rb +38 -0
- data/spec/legacy_watirspec/radio_spec.rb +286 -0
- data/spec/legacy_watirspec/radios_spec.rb +35 -0
- data/spec/legacy_watirspec/select_list_spec.rb +326 -0
- data/spec/legacy_watirspec/select_lists_spec.rb +39 -0
- data/spec/legacy_watirspec/server.rb +91 -0
- data/spec/legacy_watirspec/span_spec.rb +181 -0
- data/spec/legacy_watirspec/spans_spec.rb +64 -0
- data/spec/legacy_watirspec/spec_helper.rb +12 -0
- data/spec/legacy_watirspec/strong_spec.rb +97 -0
- data/spec/legacy_watirspec/strongs_spec.rb +39 -0
- data/spec/legacy_watirspec/table_bodies_spec.rb +61 -0
- data/spec/legacy_watirspec/table_body_spec.rb +119 -0
- data/spec/legacy_watirspec/table_cell_spec.rb +76 -0
- data/spec/legacy_watirspec/table_cells_spec.rb +71 -0
- data/spec/legacy_watirspec/table_footer_spec.rb +94 -0
- data/spec/legacy_watirspec/table_footers_spec.rb +61 -0
- data/spec/legacy_watirspec/table_header_spec.rb +98 -0
- data/spec/legacy_watirspec/table_headers_spec.rb +59 -0
- data/spec/legacy_watirspec/table_row_spec.rb +104 -0
- data/spec/legacy_watirspec/table_rows_spec.rb +64 -0
- data/spec/legacy_watirspec/table_spec.rb +170 -0
- data/spec/legacy_watirspec/tables_spec.rb +40 -0
- data/spec/legacy_watirspec/text_field_spec.rb +315 -0
- data/spec/legacy_watirspec/text_fields_spec.rb +38 -0
- data/spec/legacy_watirspec/ul_spec.rb +84 -0
- data/spec/legacy_watirspec/uls_spec.rb +40 -0
- data/spec/legacy_watirspec/watir_compatibility_spec.rb +176 -0
- data/spec/legacy_watirspec/watirspec_helper.rb +57 -0
- data/utils/Rakefile +79 -0
- data/utils/launchers/launcher-linux-i686 +0 -0
- data/utils/launchers/launcher-linux-x86_64 +0 -0
- data/utils/launchers/launcher-win32-i86pc.exe +0 -0
- metadata +404 -0
@@ -0,0 +1,244 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Div" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true if the element exists" do
|
13
|
+
browser.div(:id, "header").should exist
|
14
|
+
browser.div(:id, /header/).should exist
|
15
|
+
browser.div(:title, "Header and primary navigation").should exist
|
16
|
+
browser.div(:title, /Header and primary navigation/).should exist
|
17
|
+
browser.div(:text, "This is a footer.").should exist
|
18
|
+
browser.div(:text, /This is a footer\./).should exist
|
19
|
+
browser.div(:class, "profile").should exist
|
20
|
+
browser.div(:class, /profile/).should exist
|
21
|
+
browser.div(:index, 1).should exist
|
22
|
+
browser.div(:xpath, "//div[@id='header']").should exist
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns true if the element exists (default how = :id)" do
|
26
|
+
browser.div("header").should exist
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns the first div if given no args" do
|
30
|
+
browser.div.should exist
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns 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 "raises TypeError when 'what' argument is invalid" do
|
47
|
+
lambda { browser.div(:id, 3.14).exists? }.should raise_error(TypeError)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
51
|
+
lambda { browser.div(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# Attribute methods
|
57
|
+
describe "#class_name" do
|
58
|
+
it "returns the class attribute if the element exists" do
|
59
|
+
browser.div(:id , "footer").class_name.should == "profile"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
63
|
+
browser.div(:id , "content").class_name.should == ""
|
64
|
+
end
|
65
|
+
|
66
|
+
it "raises UnknownObjectException if the element does not exist" do
|
67
|
+
lambda { browser.div(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
68
|
+
lambda { browser.div(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
69
|
+
lambda { browser.div(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
70
|
+
lambda { browser.div(:xpath, "//div[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#id" do
|
75
|
+
it "returns the id attribute if the element exists" do
|
76
|
+
browser.div(:index, 2).id.should == "outer_container"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "returns an empty string if the element exists, but the attribute doesn't" do
|
80
|
+
browser.div(:index, 1).id.should == ""
|
81
|
+
end
|
82
|
+
|
83
|
+
it "raises UnknownObjectException if the element does not exist" do
|
84
|
+
lambda {browser.div(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
85
|
+
lambda {browser.div(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
86
|
+
lambda {browser.div(:index, 1337).id }.should raise_error(UnknownObjectException)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should take all conditions into account when locating by id" do
|
90
|
+
browser.goto WatirSpec.files + "/multiple_ids.html"
|
91
|
+
browser.div(:id => "multiple", :class => "bar").class_name.should == "bar"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#name" do
|
96
|
+
it "returns the name attribute if the element exists" do
|
97
|
+
browser.div(:id, 'promo').name.should == "invalid_attribute"
|
98
|
+
end
|
99
|
+
|
100
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
101
|
+
browser.div(:index, 1).name.should == ""
|
102
|
+
end
|
103
|
+
|
104
|
+
it "raises UnknownObjectException if the element does not exist" do
|
105
|
+
lambda {browser.div(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
106
|
+
lambda {browser.div(:title, "no_such_title").name }.should raise_error(UnknownObjectException)
|
107
|
+
lambda {browser.div(:index, 1337).name }.should raise_error(UnknownObjectException)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#style" do
|
112
|
+
not_compliant_on :watir do
|
113
|
+
it "returns the style attribute if the element exists" do
|
114
|
+
browser.div(:id, 'best_language').style.should == "color: red; text-decoration: underline; cursor: pointer;"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
deviates_on :watir do
|
119
|
+
it "returns the style attribute if the element exists" do
|
120
|
+
# just different order and missing semicolon here
|
121
|
+
browser.div(:id, 'best_language').style.should == "cursor: pointer; color: red; text-decoration: underline"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
128
|
+
browser.div(:id, 'promo').style.should == ""
|
129
|
+
end
|
130
|
+
|
131
|
+
it "raises UnknownObjectException if the element does not exist" do
|
132
|
+
lambda {browser.div(:id, "no_such_id").style }.should raise_error(UnknownObjectException)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "#text" do
|
137
|
+
it "returns the text of the div" do
|
138
|
+
browser.div(:id, "footer").text.strip.should == "This is a footer."
|
139
|
+
browser.div(:title, "Closing remarks").text.strip.should == "This is a footer."
|
140
|
+
browser.div(:xpath, "//div[@id='footer']").text.strip.should == "This is a footer."
|
141
|
+
end
|
142
|
+
|
143
|
+
it "returns an empty string if the element exists but contains no text" do
|
144
|
+
browser.div(:index, 1).text.strip.should == ""
|
145
|
+
end
|
146
|
+
|
147
|
+
deviates_on :celerity do
|
148
|
+
it "returns an empty string if the div is hidden" do
|
149
|
+
browser.div(:id, 'hidden').text.should == ""
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it "raises UnknownObjectException if the element does not exist" do
|
154
|
+
lambda { browser.div(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
155
|
+
lambda { browser.div(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
156
|
+
lambda { browser.div(:index, 1337).text }.should raise_error(UnknownObjectException)
|
157
|
+
lambda { browser.div(:xpath, "//div[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "#value" do
|
162
|
+
it "returns the value attribute if the element exists" do
|
163
|
+
browser.div(:id, 'promo').value.should == "invalid_attribute"
|
164
|
+
end
|
165
|
+
|
166
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
167
|
+
browser.div(:index, 1).value.should == ""
|
168
|
+
end
|
169
|
+
|
170
|
+
it "raises UnknownObjectException if the element does not exist" do
|
171
|
+
lambda {browser.div(:id, "no_such_id").value }.should raise_error(UnknownObjectException)
|
172
|
+
lambda {browser.div(:title, "no_such_title").value }.should raise_error(UnknownObjectException)
|
173
|
+
lambda {browser.div(:index, 1337).value }.should raise_error(UnknownObjectException)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#respond_to?" do
|
178
|
+
it "returns true for all attribute methods" do
|
179
|
+
browser.div(:index, 1).should respond_to(:class_name)
|
180
|
+
browser.div(:index, 1).should respond_to(:id)
|
181
|
+
browser.div(:index, 1).should respond_to(:name)
|
182
|
+
browser.div(:index, 1).should respond_to(:style)
|
183
|
+
browser.div(:index, 1).should respond_to(:text)
|
184
|
+
browser.div(:index, 1).should respond_to(:value)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# Manipulation methods
|
189
|
+
describe "#click" do
|
190
|
+
it "fires events when clicked" do
|
191
|
+
browser.div(:id, 'best_language').text.should_not == 'Ruby!'
|
192
|
+
browser.div(:id, 'best_language').click
|
193
|
+
browser.div(:id, 'best_language').text.should == 'Ruby!'
|
194
|
+
end
|
195
|
+
|
196
|
+
it "raises UnknownObjectException if the element does not exist" do
|
197
|
+
lambda { browser.div(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
198
|
+
lambda { browser.div(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
199
|
+
lambda { browser.div(:index, 1337).click }.should raise_error(UnknownObjectException)
|
200
|
+
lambda { browser.div(:xpath, "//div[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
not_compliant_on :watir do
|
205
|
+
describe "#double_click" do
|
206
|
+
it "fires the ondblclick event" do
|
207
|
+
browser.div(:id, 'html_test').double_click
|
208
|
+
messages.should include('double clicked')
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "#right_click" do
|
213
|
+
it "fires the oncontextmenu event" do
|
214
|
+
browser.goto(WatirSpec.files + "/right_click.html")
|
215
|
+
browser.div(:id, "click").right_click
|
216
|
+
messages.first.should == 'right-clicked'
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "#html" do
|
222
|
+
it "returns the HTML of the element" do
|
223
|
+
html = browser.div(:id, 'footer').html
|
224
|
+
html.should include('<div id="footer" title="Closing remarks" class="profile">')
|
225
|
+
html.should include('This is a footer.')
|
226
|
+
html.should_not include('<div id="content">')
|
227
|
+
html.should_not include('</body>')
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "#to_s" do
|
232
|
+
bug "WTR-350", :watir do
|
233
|
+
it "returns a human readable representation of the element" do
|
234
|
+
browser.div(:id, 'footer').to_s.should ==
|
235
|
+
%q{tag: div
|
236
|
+
id: footer
|
237
|
+
title: Closing remarks
|
238
|
+
class: profile
|
239
|
+
text: This is a footer.}
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Divs" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the number of divs" do
|
12
|
+
browser.divs.length.should == 12
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the div at the given index" do
|
18
|
+
browser.divs[2].id.should == "outer_container"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through divs correctly" do
|
24
|
+
count = 0
|
25
|
+
|
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
|
+
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
count.should > 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Dl" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/definition_lists.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Exists method
|
11
|
+
describe "#exists?" do
|
12
|
+
it "returns true if the element exists" do
|
13
|
+
browser.dl(:id, "experience-list").should exist
|
14
|
+
browser.dl(:class, "list").should exist
|
15
|
+
browser.dl(:xpath, "//dl[@id='experience-list']").should exist
|
16
|
+
browser.dl(:index, 1).should exist
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns the first dl if given no args" do
|
20
|
+
browser.dl.should exist
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns false if the element does not exist" do
|
24
|
+
browser.dl(:id, "no_such_id").should_not exist
|
25
|
+
end
|
26
|
+
|
27
|
+
it "raises TypeError when 'what' argument is invalid" do
|
28
|
+
lambda { browser.dl(:id, 3.14).exists? }.should raise_error(TypeError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
32
|
+
lambda { browser.dl(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute methods
|
37
|
+
describe "#class_name" do
|
38
|
+
it "returns the class attribute if the element exists" do
|
39
|
+
browser.dl(:id , "experience-list").class_name.should == "list"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
43
|
+
browser.dl(:id , "noop").class_name.should == ""
|
44
|
+
end
|
45
|
+
|
46
|
+
it "raises UnknownObjectException if the element does not exist" do
|
47
|
+
lambda { browser.dl(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
48
|
+
lambda { browser.dl(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
49
|
+
lambda { browser.dl(:index, 1337).class_name }.should raise_error(UnknownObjectException)
|
50
|
+
lambda { browser.dl(:xpath, "//dl[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#id" do
|
55
|
+
it "returns the id attribute if the element exists" do
|
56
|
+
browser.dl(:class, 'list').id.should == "experience-list"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns an empty string if the element exists, but the attribute doesn't" do
|
60
|
+
browser.dl(:class, 'personalia').id.should == ""
|
61
|
+
end
|
62
|
+
|
63
|
+
it "raises UnknownObjectException if the element does not exist" do
|
64
|
+
lambda {browser.dl(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
65
|
+
lambda {browser.dl(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
66
|
+
lambda {browser.dl(:index, 1337).id }.should raise_error(UnknownObjectException)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#title" do
|
71
|
+
it "returns the id attribute if the element exists" do
|
72
|
+
browser.dl(:class, 'list').title.should == "experience"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#text" do
|
77
|
+
it "returns the text of the element" do
|
78
|
+
browser.dl(:id, "experience-list").text.should include("11 years")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns an empty string if the element exists but contains no text" do
|
82
|
+
browser.dl(:id, 'noop').text.should == ""
|
83
|
+
end
|
84
|
+
|
85
|
+
it "raises UnknownObjectException if the element does not exist" do
|
86
|
+
lambda { browser.dl(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
87
|
+
lambda { browser.dl(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
88
|
+
lambda { browser.dl(:index, 1337).text }.should raise_error(UnknownObjectException)
|
89
|
+
lambda { browser.dl(:xpath, "//dl[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#respond_to?" do
|
94
|
+
it "returns true for all attribute methods" do
|
95
|
+
browser.dl(:index, 1).should respond_to(:id)
|
96
|
+
browser.dl(:index, 1).should respond_to(:class_name)
|
97
|
+
browser.dl(:index, 1).should respond_to(:style)
|
98
|
+
browser.dl(:index, 1).should respond_to(:text)
|
99
|
+
browser.dl(:index, 1).should respond_to(:title)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Manipulation methods
|
104
|
+
describe "#click" do
|
105
|
+
it "fires events when clicked" do
|
106
|
+
browser.dl(:id, 'noop').text.should_not == 'noop'
|
107
|
+
browser.dl(:id, 'noop').click
|
108
|
+
browser.dl(:id, 'noop').text.should == 'noop'
|
109
|
+
end
|
110
|
+
|
111
|
+
it "raises UnknownObjectException if the element does not exist" do
|
112
|
+
lambda { browser.dl(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
113
|
+
lambda { browser.dl(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
114
|
+
lambda { browser.dl(:index, 1337).click }.should raise_error(UnknownObjectException)
|
115
|
+
lambda { browser.dl(:xpath, "//dl[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#html" do
|
120
|
+
it "returns the HTML of the element" do
|
121
|
+
html = browser.dl(:id, 'experience-list').html
|
122
|
+
html.should include('<dt class="current-industry">')
|
123
|
+
html.should_not include('</body>')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#to_s" do
|
128
|
+
bug "WTR-350", :watir do
|
129
|
+
it "returns a human readable representation of the element" do
|
130
|
+
browser.dl(:id, 'experience-list').to_s.should ==
|
131
|
+
%q{tag: dl
|
132
|
+
id: experience-list
|
133
|
+
class: list
|
134
|
+
title: experience
|
135
|
+
text: Experience 11 years Education Master Current industry Architecture Previous industry experience Architecture}
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
describe "Dls" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/definition_lists.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#length" do
|
11
|
+
it "returns the number of dls" do
|
12
|
+
browser.dls.length.should == 3
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#[]" do
|
17
|
+
it "returns the dl at the given index" do
|
18
|
+
browser.dls[1].id.should == "experience-list"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#each" do
|
23
|
+
it "iterates through dls correctly" do
|
24
|
+
count = 0
|
25
|
+
|
26
|
+
browser.dls.each_with_index do |d, index|
|
27
|
+
d.text.should == browser.dl(:index, index+1).text
|
28
|
+
d.id.should == browser.dl(:index, index+1).id
|
29
|
+
d.class_name.should == browser.dl(:index, index+1).class_name
|
30
|
+
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
count.should > 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|