watir 7.2.0 → 7.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/chrome.yml +1 -1
- data/.github/workflows/edge.yml +1 -1
- data/.github/workflows/firefox.yml +1 -1
- data/.github/workflows/ie.yml +1 -1
- data/.github/workflows/safari.yml +1 -1
- data/.github/workflows/unit.yml +1 -1
- data/.rubocop.yml +25 -12
- data/.rubocop_todo.yml +8 -1
- data/CHANGES.md +6 -1
- data/LICENSE +2 -2
- data/lib/watir/capabilities.rb +1 -1
- data/lib/watir/locators/anchor/selector_builder.rb +3 -0
- data/lib/watir/locators/element/matcher.rb +2 -1
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +2 -1
- data/lib/watir/locators/text_field/matcher.rb +0 -4
- data/lib/watir/version.rb +1 -1
- data/spec/locator_spec_helper.rb +0 -8
- data/spec/unit/capabilities_spec.rb +553 -561
- data/spec/unit/element_locator_spec.rb +89 -78
- data/spec/unit/match_elements/button_spec.rb +69 -62
- data/spec/unit/match_elements/element_spec.rb +303 -309
- data/spec/unit/match_elements/text_field_spec.rb +76 -73
- data/spec/unit/selector_builder/anchor_spec.rb +39 -33
- data/spec/unit/selector_builder/button_spec.rb +209 -202
- data/spec/unit/selector_builder/cell_spec.rb +48 -42
- data/spec/unit/selector_builder/element_spec.rb +634 -627
- data/spec/unit/selector_builder/row_spec.rb +119 -113
- data/spec/unit/selector_builder/text_field_spec.rb +195 -188
- data/spec/unit/selector_builder/textarea_spec.rb +22 -14
- data/spec/unit/wait_spec.rb +85 -81
- data/spec/watirspec/adjacent_spec.rb +249 -247
- data/spec/watirspec/after_hooks_spec.rb +161 -159
- data/spec/watirspec/alert_spec.rb +61 -58
- data/spec/watirspec/browser_spec.rb +409 -409
- data/spec/watirspec/capabilities_spec.rb +89 -99
- data/spec/watirspec/cookies_spec.rb +120 -118
- data/spec/watirspec/drag_and_drop_spec.rb +26 -24
- data/spec/watirspec/element_hidden_spec.rb +66 -60
- data/spec/watirspec/elements/area_spec.rb +49 -47
- data/spec/watirspec/elements/areas_spec.rb +27 -25
- data/spec/watirspec/elements/button_spec.rb +253 -251
- data/spec/watirspec/elements/buttons_spec.rb +36 -34
- data/spec/watirspec/elements/checkbox_spec.rb +48 -36
- data/spec/watirspec/elements/checkboxes_spec.rb +29 -27
- data/spec/watirspec/elements/collections_spec.rb +126 -119
- data/spec/watirspec/elements/date_field_spec.rb +185 -183
- data/spec/watirspec/elements/date_fields_spec.rb +29 -27
- data/spec/watirspec/elements/date_time_field_spec.rb +197 -195
- data/spec/watirspec/elements/date_time_fields_spec.rb +30 -28
- data/spec/watirspec/elements/dd_spec.rb +87 -85
- data/spec/watirspec/elements/dds_spec.rb +27 -25
- data/spec/watirspec/elements/del_spec.rb +106 -104
- data/spec/watirspec/elements/dels_spec.rb +26 -24
- data/spec/watirspec/elements/div_spec.rb +225 -221
- data/spec/watirspec/elements/divs_spec.rb +37 -35
- data/spec/watirspec/elements/dl_spec.rb +110 -108
- data/spec/watirspec/elements/dls_spec.rb +28 -26
- data/spec/watirspec/elements/dt_spec.rb +86 -84
- data/spec/watirspec/elements/dts_spec.rb +27 -25
- data/spec/watirspec/elements/element_spec.rb +794 -775
- data/spec/watirspec/elements/elements_spec.rb +40 -38
- data/spec/watirspec/elements/em_spec.rb +62 -60
- data/spec/watirspec/elements/ems_spec.rb +28 -26
- data/spec/watirspec/elements/filefield_spec.rb +116 -114
- data/spec/watirspec/elements/filefields_spec.rb +28 -26
- data/spec/watirspec/elements/font_spec.rb +20 -18
- data/spec/watirspec/elements/form_spec.rb +51 -49
- data/spec/watirspec/elements/forms_spec.rb +29 -27
- data/spec/watirspec/elements/frame_spec.rb +89 -87
- data/spec/watirspec/elements/frames_spec.rb +27 -25
- data/spec/watirspec/elements/hidden_spec.rb +81 -79
- data/spec/watirspec/elements/hiddens_spec.rb +28 -26
- data/spec/watirspec/elements/hn_spec.rb +59 -57
- data/spec/watirspec/elements/hns_spec.rb +26 -24
- data/spec/watirspec/elements/iframe_spec.rb +195 -191
- data/spec/watirspec/elements/iframes_spec.rb +31 -29
- data/spec/watirspec/elements/image_spec.rb +148 -146
- data/spec/watirspec/elements/images_spec.rb +26 -24
- data/spec/watirspec/elements/input_spec.rb +9 -7
- data/spec/watirspec/elements/ins_spec.rb +106 -104
- data/spec/watirspec/elements/inses_spec.rb +26 -24
- data/spec/watirspec/elements/label_spec.rb +56 -54
- data/spec/watirspec/elements/labels_spec.rb +26 -24
- data/spec/watirspec/elements/li_spec.rb +76 -74
- data/spec/watirspec/elements/link_spec.rb +173 -177
- data/spec/watirspec/elements/links_spec.rb +45 -43
- data/spec/watirspec/elements/lis_spec.rb +27 -25
- data/spec/watirspec/elements/list_spec.rb +44 -42
- data/spec/watirspec/elements/map_spec.rb +57 -55
- data/spec/watirspec/elements/maps_spec.rb +27 -25
- data/spec/watirspec/elements/meta_spec.rb +16 -14
- data/spec/watirspec/elements/metas_spec.rb +26 -24
- data/spec/watirspec/elements/ol_spec.rb +56 -65
- data/spec/watirspec/elements/ols_spec.rb +26 -24
- data/spec/watirspec/elements/option_spec.rb +91 -89
- data/spec/watirspec/elements/p_spec.rb +81 -79
- data/spec/watirspec/elements/pre_spec.rb +77 -75
- data/spec/watirspec/elements/pres_spec.rb +26 -24
- data/spec/watirspec/elements/ps_spec.rb +26 -24
- data/spec/watirspec/elements/radio_spec.rb +251 -249
- data/spec/watirspec/elements/radios_spec.rb +28 -26
- data/spec/watirspec/elements/select_list_spec.rb +537 -526
- data/spec/watirspec/elements/select_lists_spec.rb +32 -30
- data/spec/watirspec/elements/span_spec.rb +112 -110
- data/spec/watirspec/elements/spans_spec.rb +26 -24
- data/spec/watirspec/elements/strong_spec.rb +58 -58
- data/spec/watirspec/elements/strongs_spec.rb +28 -26
- data/spec/watirspec/elements/table_spec.rb +192 -139
- data/spec/watirspec/elements/tables_spec.rb +28 -26
- data/spec/watirspec/elements/tbody_spec.rb +74 -72
- data/spec/watirspec/elements/tbodys_spec.rb +40 -38
- data/spec/watirspec/elements/td_spec.rb +66 -64
- data/spec/watirspec/elements/tds_spec.rb +41 -39
- data/spec/watirspec/elements/text_field_spec.rb +206 -204
- data/spec/watirspec/elements/text_fields_spec.rb +30 -28
- data/spec/watirspec/elements/textarea_spec.rb +20 -18
- data/spec/watirspec/elements/textareas_spec.rb +18 -16
- data/spec/watirspec/elements/tfoot_spec.rb +65 -63
- data/spec/watirspec/elements/tfoots_spec.rb +42 -40
- data/spec/watirspec/elements/thead_spec.rb +65 -63
- data/spec/watirspec/elements/theads_spec.rb +42 -40
- data/spec/watirspec/elements/tr_spec.rb +48 -46
- data/spec/watirspec/elements/trs_spec.rb +42 -40
- data/spec/watirspec/elements/ul_spec.rb +56 -54
- data/spec/watirspec/elements/uls_spec.rb +26 -24
- data/spec/watirspec/radio_set_spec.rb +269 -267
- data/spec/watirspec/screenshot_spec.rb +20 -18
- data/spec/watirspec/scroll_spec.rb +152 -148
- data/spec/watirspec/shadow_root_spec.rb +86 -83
- data/spec/watirspec/user_editable_spec.rb +200 -198
- data/spec/watirspec/wait_spec.rb +289 -295
- data/spec/watirspec/window_switching_spec.rb +422 -434
- data/spec/watirspec_helper.rb +1 -23
- data/watir.gemspec +5 -4
- metadata +44 -33
- data/spec/watirspec/attributes_spec.rb +0 -18
- data/spec/watirspec/elements/table_nesting_spec.rb +0 -51
- data/spec/watirspec/special_chars_spec.rb +0 -23
@@ -2,227 +2,231 @@
|
|
2
2
|
|
3
3
|
require 'watirspec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
5
|
+
module Watir
|
6
|
+
describe Div do
|
7
|
+
before do
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#exists?' do
|
12
|
+
it 'returns true if the element exists' do
|
13
|
+
expect(browser.div(id: 'header')).to exist
|
14
|
+
expect(browser.div(id: /header/)).to exist
|
15
|
+
expect(browser.div(title: 'Header and primary navigation')).to exist
|
16
|
+
expect(browser.div(title: /Header and primary navigation/)).to exist
|
17
|
+
expect(browser.div(text: 'Not shownNot hidden')).to exist
|
18
|
+
expect(browser.div(text: /Not hidden/)).to exist
|
19
|
+
expect(browser.div(class: 'profile')).to exist
|
20
|
+
expect(browser.div(class: /profile/)).to exist
|
21
|
+
expect(browser.div(index: 0)).to exist
|
22
|
+
expect(browser.div(xpath: "//div[@id='header']")).to exist
|
23
|
+
expect(browser.div(custom_attribute: 'custom')).to exist
|
24
|
+
expect(browser.div(custom_attribute: /custom/)).to exist
|
25
|
+
expect(browser.div(text: /some visible/)).to exist
|
26
|
+
expect(browser.div(text: /some (visible|Jeff)/)).to exist
|
27
|
+
expect(browser.div(text: /none visible/)).to exist
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns the first div if given no args' do
|
31
|
+
expect(browser.div).to exist
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns false if the element does not exist' do
|
35
|
+
expect(browser.div(id: 'no_such_id')).not_to exist
|
36
|
+
expect(browser.div(id: /no_such_id/)).not_to exist
|
37
|
+
expect(browser.div(title: 'no_such_title')).not_to exist
|
38
|
+
expect(browser.div(title: /no_such_title/)).not_to exist
|
39
|
+
expect(browser.div(text: 'no_such_text')).not_to exist
|
40
|
+
expect(browser.div(text: /no_such_text/)).not_to exist
|
41
|
+
expect(browser.div(class: 'no_such_class')).not_to exist
|
42
|
+
expect(browser.div(class: /no_such_class/)).not_to exist
|
43
|
+
expect(browser.div(text: /some visible some hidden/)).to exist
|
44
|
+
expect(browser.div(index: 1337)).not_to exist
|
45
|
+
expect(browser.div(xpath: "//div[@id='no_such_id']")).not_to exist
|
46
|
+
end
|
47
|
+
|
48
|
+
it "raises TypeError when 'what' argument is invalid" do
|
49
|
+
expect { browser.div(id: 3.14).exists? }.to raise_error(TypeError)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Attribute methods
|
54
|
+
describe '#id' do
|
55
|
+
it 'returns the id attribute if the element exists' do
|
56
|
+
expect(browser.div(index: 1).id).to eq 'outer_container'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns an empty string if the element exists, but the attribute doesn't" do
|
60
|
+
expect(browser.div(index: 0).id).to eq ''
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
64
|
+
expect { browser.div(id: 'no_such_id').id }.to raise_unknown_object_exception
|
65
|
+
expect { browser.div(title: 'no_such_id').id }.to raise_unknown_object_exception
|
66
|
+
expect { browser.div(index: 1337).id }.to raise_unknown_object_exception
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'takes all conditions into account when locating by id' do
|
70
|
+
browser.goto WatirSpec.url_for 'multiple_ids.html'
|
71
|
+
expect(browser.div(id: 'multiple', class: 'bar').class_name).to eq 'bar'
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'finds the id with the correct tag name' do
|
75
|
+
browser.goto WatirSpec.url_for 'multiple_ids.html'
|
76
|
+
expect(browser.span(id: 'multiple').class_name).to eq 'foobar'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#style' do
|
81
|
+
it 'returns the style attribute if the element exists' do
|
82
|
+
expect(browser.div(id: 'best_language').style).to eq 'color: red; text-decoration: underline; cursor: pointer;'
|
83
|
+
end
|
84
|
+
|
85
|
+
it "returns an empty string if the element exists but the attribute doesn't" do
|
86
|
+
expect(browser.div(id: 'promo').style).to eq ''
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
90
|
+
expect { browser.div(id: 'no_such_id').style }.to raise_unknown_object_exception
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#text' do
|
95
|
+
it 'returns the text of the div' do
|
96
|
+
expect(browser.div(id: 'footer').text.strip).to eq 'This is a footer.'
|
97
|
+
expect(browser.div(title: 'Closing remarks').text.strip).to eq 'This is a footer.'
|
98
|
+
expect(browser.div(xpath: "//div[@id='footer']").text.strip).to eq 'This is a footer.'
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'returns an empty string if the element exists but contains no text' do
|
102
|
+
expect(browser.div(index: 0).text.strip).to eq ''
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'returns an empty string if the div is hidden',
|
106
|
+
except: {browser: :safari, reason: 'Safari is not filtering out hidden text'} do
|
107
|
+
expect(browser.div(id: 'hidden').text).to eq ''
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
111
|
+
expect { browser.div(id: 'no_such_id').text }.to raise_unknown_object_exception
|
112
|
+
expect { browser.div(title: 'no_such_title').text }.to raise_unknown_object_exception
|
113
|
+
expect { browser.div(index: 1337).text }.to raise_unknown_object_exception
|
114
|
+
expect { browser.div(xpath: "//div[@id='no_such_id']").text }.to raise_unknown_object_exception
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe 'custom methods' do
|
119
|
+
it 'returns the custom attribute if the element exists' do
|
120
|
+
expect(browser.div(custom_attribute: 'custom').attribute_value('custom-attribute')).to eq 'custom'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#respond_to?' do
|
125
|
+
it 'returns true for all attribute methods' do
|
126
|
+
expect(browser.div(index: 0)).to respond_to(:class_name)
|
127
|
+
expect(browser.div(index: 0)).to respond_to(:id)
|
128
|
+
expect(browser.div(index: 0)).to respond_to(:style)
|
129
|
+
expect(browser.div(index: 0)).to respond_to(:text)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Manipulation methods
|
134
|
+
describe '#click' do
|
135
|
+
it 'fires events when clicked' do
|
136
|
+
expect(browser.div(id: 'best_language').text).not_to eq 'Ruby!'
|
137
|
+
|
138
|
+
div = browser.div(id: 'best_language')
|
139
|
+
div.scroll.to
|
140
|
+
div.click
|
141
|
+
expect(browser.div(id: 'best_language').text).to eq 'Ruby!'
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
145
|
+
expect { browser.div(id: 'no_such_id').click }.to raise_unknown_object_exception
|
146
|
+
expect { browser.div(title: 'no_such_title').click }.to raise_unknown_object_exception
|
147
|
+
expect { browser.div(index: 1337).click }.to raise_unknown_object_exception
|
148
|
+
expect { browser.div(xpath: "//div[@id='no_such_id']").click }.to raise_unknown_object_exception
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'includes custom message if element with a custom attribute does not exist' do
|
152
|
+
message = /Watir treated \["custom_attribute"\] as a non-HTML compliant attribute, ensure that was intended/
|
153
|
+
expect { browser.div(custom_attribute: 'not_there').click }.to raise_unknown_object_exception(message)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe '#click!' do
|
158
|
+
it 'fires events when clicked' do
|
159
|
+
expect(browser.div(id: 'best_language').text).not_to eq 'Ruby!'
|
160
|
+
browser.div(id: 'best_language').click!
|
161
|
+
expect(browser.div(id: 'best_language').text).to eq 'Ruby!'
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
165
|
+
expect { browser.div(id: 'no_such_id').click! }.to raise_unknown_object_exception
|
166
|
+
expect { browser.div(title: 'no_such_title').click! }.to raise_unknown_object_exception
|
167
|
+
expect { browser.div(index: 1337).click! }.to raise_unknown_object_exception
|
168
|
+
expect { browser.div(xpath: "//div[@id='no_such_id']").click! }.to raise_unknown_object_exception
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe '#double_click',
|
173
|
+
except: {browser: :safari, reason: 'command correctly received, but action not taken'} do
|
174
|
+
it 'fires the ondblclick event' do
|
175
|
+
div = browser.div(id: 'html_test')
|
176
|
+
div.double_click
|
177
|
+
expect(messages).to include('double clicked')
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'fires the ondblclick event with specified scroll position' do
|
181
|
+
div = browser.div(id: 'html_test')
|
182
|
+
div.double_click(scroll_to: :center)
|
183
|
+
expect(messages).to include('double clicked')
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe '#double_click!' do
|
188
|
+
it 'fires the ondblclick event' do
|
189
|
+
browser.div(id: 'html_test').double_click!
|
190
|
+
expect(messages).to include('double clicked')
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe '#right_click' do
|
195
|
+
it 'fires the oncontextmenu event' do
|
196
|
+
browser.goto(WatirSpec.url_for('right_click.html'))
|
197
|
+
browser.div(id: 'click').right_click
|
198
|
+
expect(messages.first).to eq 'right-clicked'
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'accepts modifiers', except: {browser: :ie} do
|
202
|
+
browser.goto(WatirSpec.url_for('right_click.html'))
|
203
|
+
browser.div(id: 'click-logger').right_click(:control, :alt)
|
204
|
+
expect(event_log.first).to eq('control=true alt=true')
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'accepts modifiers with scroll position', except: {browser: :ie} do
|
208
|
+
browser.goto(WatirSpec.url_for('right_click.html'))
|
209
|
+
browser.div(id: 'click-logger').right_click(:control, :alt, scroll_to: :center)
|
210
|
+
expect(event_log.first).to eq('control=true alt=true')
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'scrolls' do
|
214
|
+
expect {
|
215
|
+
browser.del(class: 'footer').double_click
|
216
|
+
}.not_to raise_exception
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe '#html' do
|
221
|
+
it 'returns the HTML of the element' do
|
222
|
+
html = browser.div(id: 'footer').html.downcase
|
223
|
+
expect(html).to include('id="footer"')
|
224
|
+
expect(html).to include('title="closing remarks"')
|
225
|
+
expect(html).to include('class="profile"')
|
226
|
+
|
227
|
+
expect(html).not_to include('<div id="content">')
|
228
|
+
expect(html).not_to include('</body>')
|
229
|
+
end
|
226
230
|
end
|
227
231
|
end
|
228
232
|
end
|
@@ -2,53 +2,55 @@
|
|
2
2
|
|
3
3
|
require 'watirspec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
describe 'with selectors' do
|
11
|
-
it 'returns the matching elements' do
|
12
|
-
expect(browser.divs(id: 'header').to_a).to eq [browser.div(id: 'header')]
|
5
|
+
module Watir
|
6
|
+
describe DivCollection do
|
7
|
+
before do
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
13
9
|
end
|
14
|
-
end
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
describe 'with selectors' do
|
12
|
+
it 'returns the matching elements' do
|
13
|
+
expect(browser.divs(id: 'header').to_a).to eq [browser.div(id: 'header')]
|
14
|
+
end
|
19
15
|
end
|
20
|
-
end
|
21
16
|
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
describe '#length' do
|
18
|
+
it 'returns the number of divs' do
|
19
|
+
expect(browser.divs.length).to eq 20
|
20
|
+
end
|
25
21
|
end
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
describe '#[]' do
|
24
|
+
it 'returns the div at the given index' do
|
25
|
+
expect(browser.divs[1].id).to eq 'outer_container'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns an array of divs with a given range of positive values' do
|
29
|
+
divs = browser.divs[2..4]
|
30
|
+
ids = divs.map(&:id)
|
31
|
+
expect(ids).to eq %w[header promo content]
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
it 'returns an array of divs with a given range including negative values' do
|
35
|
+
divs = browser.divs[11..-7]
|
36
|
+
ids = divs.map(&:id)
|
37
|
+
expect(ids).to eq %w[messages ins_tag_test del_tag_test]
|
38
|
+
end
|
37
39
|
end
|
38
|
-
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
describe '#each' do
|
42
|
+
it 'iterates through divs correctly' do
|
43
|
+
count = 0
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
browser.divs.each_with_index do |d, index|
|
46
|
+
expect(d.id).to eq browser.div(index: index).id
|
47
|
+
expect(d.class_name).to eq browser.div(index: index).class_name
|
47
48
|
|
48
|
-
|
49
|
-
|
49
|
+
count += 1
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
+
expect(count).to be > 0
|
53
|
+
end
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|