watir 7.0.0.beta1 → 7.0.0.beta5
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.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +7 -3
- data/.rubocop.yml +2 -7
- data/CHANGES.md +32 -0
- data/lib/watir/browser.rb +21 -7
- data/lib/watir/capabilities.rb +52 -7
- data/lib/watir/elements/date_field.rb +4 -1
- data/lib/watir/elements/date_time_field.rb +4 -1
- data/lib/watir/elements/element.rb +32 -3
- data/lib/watir/elements/font.rb +1 -0
- data/lib/watir/elements/iframe.rb +0 -1
- data/lib/watir/elements/radio.rb +2 -2
- data/lib/watir/elements/select.rb +63 -40
- data/lib/watir/has_window.rb +2 -0
- data/lib/watir/locators.rb +4 -0
- data/lib/watir/locators/element/matcher.rb +1 -1
- data/lib/watir/locators/element/selector_builder.rb +0 -3
- data/lib/watir/locators/element/selector_builder/xpath.rb +2 -1
- data/lib/watir/locators/option/matcher.rb +24 -0
- data/lib/watir/locators/option/selector_builder.rb +8 -0
- data/lib/watir/locators/option/selector_builder/xpath.rb +37 -0
- data/lib/watir/logger.rb +3 -74
- data/lib/watir/radio_set.rb +1 -0
- data/lib/watir/screenshot.rb +2 -8
- data/lib/watir/user_editable.rb +10 -3
- data/lib/watir/version.rb +1 -1
- data/lib/watir/window.rb +15 -4
- data/lib/watir/window_collection.rb +9 -0
- data/lib/watirspec.rb +4 -2
- data/lib/watirspec/guards.rb +1 -1
- data/lib/watirspec/remote_server.rb +2 -6
- data/lib/watirspec/server.rb +1 -1
- data/spec/spec_helper.rb +0 -10
- data/spec/unit/capabilities_spec.rb +198 -48
- data/spec/unit/match_elements/element_spec.rb +11 -0
- data/spec/watirspec/after_hooks_spec.rb +22 -45
- data/spec/watirspec/browser_spec.rb +185 -206
- data/spec/watirspec/cookies_spec.rb +47 -52
- data/spec/watirspec/drag_and_drop_spec.rb +5 -7
- data/spec/watirspec/elements/area_spec.rb +1 -5
- data/spec/watirspec/elements/button_spec.rb +4 -8
- data/spec/watirspec/elements/checkbox_spec.rb +2 -4
- data/spec/watirspec/elements/date_field_spec.rb +13 -16
- data/spec/watirspec/elements/date_time_field_spec.rb +14 -13
- data/spec/watirspec/elements/dd_spec.rb +3 -4
- data/spec/watirspec/elements/del_spec.rb +10 -12
- data/spec/watirspec/elements/div_spec.rb +41 -50
- data/spec/watirspec/elements/dl_spec.rb +4 -12
- data/spec/watirspec/elements/element_spec.rb +155 -89
- data/spec/watirspec/elements/elements_spec.rb +8 -9
- data/spec/watirspec/elements/filefield_spec.rb +5 -7
- data/spec/watirspec/elements/form_spec.rb +1 -1
- data/spec/watirspec/elements/forms_spec.rb +3 -5
- data/spec/watirspec/elements/frame_spec.rb +17 -22
- data/spec/watirspec/elements/iframe_spec.rb +21 -27
- data/spec/watirspec/elements/ins_spec.rb +10 -12
- data/spec/watirspec/elements/link_spec.rb +24 -26
- data/spec/watirspec/elements/links_spec.rb +8 -9
- data/spec/watirspec/elements/radio_spec.rb +11 -14
- data/spec/watirspec/elements/select_list_spec.rb +248 -117
- data/spec/watirspec/elements/span_spec.rb +10 -12
- data/spec/watirspec/elements/table_nesting_spec.rb +31 -34
- data/spec/watirspec/elements/table_spec.rb +11 -13
- data/spec/watirspec/elements/tbody_spec.rb +10 -12
- data/spec/watirspec/elements/td_spec.rb +4 -6
- data/spec/watirspec/elements/text_field_spec.rb +10 -12
- data/spec/watirspec/elements/tr_spec.rb +5 -7
- data/spec/watirspec/support/rspec_matchers.rb +1 -1
- data/spec/watirspec/user_editable_spec.rb +26 -28
- data/spec/watirspec/wait_spec.rb +255 -258
- data/spec/watirspec/window_switching_spec.rb +199 -200
- data/spec/watirspec_helper.rb +34 -31
- data/watir.gemspec +1 -1
- metadata +7 -8
- data/spec/implementation_spec.rb +0 -24
- data/spec/unit/logger_spec.rb +0 -81
@@ -47,15 +47,13 @@ describe 'Frame' do
|
|
47
47
|
expect(browser.frame(xpath: "//frame[@id='no_such_id']")).to_not exist
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
browser.goto(WatirSpec.url_for('nested_frames.html'))
|
50
|
+
it 'handles nested frames' do
|
51
|
+
browser.goto(WatirSpec.url_for('nested_frames.html'))
|
53
52
|
|
54
|
-
|
53
|
+
browser.frame(id: 'two').frame(id: 'three').link(id: 'four').click
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
end
|
55
|
+
browser.wait_until(title: 'definition_lists')
|
56
|
+
expect { browser.goto(WatirSpec.url_for('nested_frames.html')) }.to_not raise_exception
|
59
57
|
end
|
60
58
|
|
61
59
|
it "raises TypeError when 'what' argument is invalid" do
|
@@ -88,24 +86,21 @@ describe 'Frame' do
|
|
88
86
|
expect(browser.frame(index: 0).text_field(name: 'senderElement').value).to eq 'new value'
|
89
87
|
end
|
90
88
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
expect(el.attribute_value('cols')).to be_kind_of(String)
|
96
|
-
end
|
89
|
+
it "can access the frame's parent element after use" do
|
90
|
+
el = browser.frameset
|
91
|
+
el.frame.text_field.value
|
92
|
+
expect(el.attribute_value('cols')).to be_kind_of(String)
|
97
93
|
end
|
98
94
|
|
99
95
|
describe '#execute_script' do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
96
|
+
it 'executes the given javascript in the specified frame',
|
97
|
+
except: {browser: :safari, reason: 'Safari does not strip text'} do
|
98
|
+
frame = browser.frame(index: 0)
|
99
|
+
expect(frame.div(id: 'set_by_js').text).to eq ''
|
100
|
+
inner_html = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
101
|
+
frame.execute_script(%{document.getElementById('set_by_js').innerHTML = '#{inner_html}'})
|
102
|
+
text = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
103
|
+
expect(frame.div(id: 'set_by_js').text).to eq text
|
109
104
|
end
|
110
105
|
end
|
111
106
|
|
@@ -9,18 +9,13 @@ describe 'IFrame' do
|
|
9
9
|
browser.goto(WatirSpec.url_for('iframes.html'))
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
%i[firefox linux] do
|
15
|
-
it 'handles crossframe javascript' do
|
16
|
-
browser.goto WatirSpec.url_for('iframes.html')
|
12
|
+
it 'handles crossframe javascript' do
|
13
|
+
browser.goto WatirSpec.url_for('iframes.html')
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
15
|
+
expect(browser.iframe(id: 'iframe_1').text_field(name: 'senderElement').value).to eq 'send_this_value'
|
16
|
+
expect(browser.iframe(id: 'iframe_2').text_field(name: 'recieverElement').value).to eq 'old_value'
|
17
|
+
browser.iframe(id: 'iframe_1').button(id: 'send').click
|
18
|
+
expect(browser.iframe(id: 'iframe_2').text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
24
19
|
end
|
25
20
|
|
26
21
|
it 'locates an element defined by Selenium Element' do
|
@@ -116,13 +111,13 @@ describe 'IFrame' do
|
|
116
111
|
expect(browser.iframe(id: 'no_such_id').element).to_not exist
|
117
112
|
end
|
118
113
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
browser.iframe(id: 'two').iframe(id: 'three').link(id: 'four').click
|
114
|
+
it 'handles nested iframes' do
|
115
|
+
browser.goto(WatirSpec.url_for('nested_iframes.html'))
|
116
|
+
browser.iframe(id: 'two').iframe(id: 'three').link(id: 'four').click
|
123
117
|
|
124
|
-
|
125
|
-
|
118
|
+
expect {
|
119
|
+
browser.wait_until { |b| b.title == 'definition_lists' }
|
120
|
+
}.not_to raise_exception
|
126
121
|
end
|
127
122
|
|
128
123
|
it "raises TypeError when 'what' argument is invalid" do
|
@@ -200,16 +195,15 @@ describe 'IFrame' do
|
|
200
195
|
end
|
201
196
|
|
202
197
|
describe '#execute_script' do
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
end
|
198
|
+
it 'executes the given javascript in the specified frame',
|
199
|
+
except: {browser: :safari, reason: 'Safari does not strip text'} do
|
200
|
+
frame = browser.iframe(index: 0)
|
201
|
+
expect(frame.div(id: 'set_by_js').text).to eq ''
|
202
|
+
inner_html = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
203
|
+
script = "document.getElementById('set_by_js').innerHTML = '#{inner_html}'"
|
204
|
+
frame.execute_script script
|
205
|
+
text = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
206
|
+
expect(frame.div(id: 'set_by_js').text).to eq text
|
213
207
|
end
|
214
208
|
end
|
215
209
|
|
@@ -94,18 +94,16 @@ describe 'Ins' do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
# Other
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
expect { browser.ins(title: 'no_such_title').click }.to raise_unknown_object_exception
|
108
|
-
end
|
97
|
+
describe '#click', except: {headless: true} do
|
98
|
+
it 'fires events' do
|
99
|
+
expect(browser.ins(class: 'footer').text).to_not include('Javascript')
|
100
|
+
browser.ins(class: 'footer').click
|
101
|
+
expect(browser.ins(class: 'footer').text).to include('Javascript')
|
102
|
+
end
|
103
|
+
|
104
|
+
it "raises UnknownObjectException if the ins doesn't exist" do
|
105
|
+
expect { browser.ins(id: 'no_such_id').click }.to raise_unknown_object_exception
|
106
|
+
expect { browser.ins(title: 'no_such_title').click }.to raise_unknown_object_exception
|
109
107
|
end
|
110
108
|
end
|
111
109
|
end
|
@@ -14,9 +14,7 @@ describe 'Link' do
|
|
14
14
|
expect(browser.link(title: /link_title_2/)).to exist
|
15
15
|
expect(browser.link(text: 'Link 2')).to exist
|
16
16
|
expect(browser.link(text: /Link 2/i)).to exist
|
17
|
-
|
18
|
-
expect(browser.link(href: 'non_control_elements.html')).to exist
|
19
|
-
end
|
17
|
+
expect(browser.link(href: 'non_control_elements.html')).to exist
|
20
18
|
expect(browser.link(href: /non_control_elements.html/)).to exist
|
21
19
|
expect(browser.link(index: 1)).to exist
|
22
20
|
expect(browser.link(xpath: "//a[@id='link_2']")).to exist
|
@@ -123,35 +121,36 @@ describe 'Link' do
|
|
123
121
|
end
|
124
122
|
|
125
123
|
# Manipulation methods
|
124
|
+
# Note: the #wait_until calls are hacks for Safari specifically
|
126
125
|
describe '#click' do
|
127
126
|
it 'finds an existing link by (text: String) and clicks it' do
|
128
|
-
browser.link(text: 'Link 3')
|
129
|
-
|
127
|
+
element = browser.link(text: 'Link 3')
|
128
|
+
element.wait_until { |link| !link.exist? || link.click }
|
129
|
+
expect(browser.h1(text: 'User administration')).to exist
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'finds an existing link by (text: Regexp) and clicks it' do
|
133
|
-
browser.link(href: /forms_with_input_elements/)
|
134
|
-
|
133
|
+
element = browser.link(href: /forms_with_input_elements/)
|
134
|
+
element.wait_until { |link| !link.exist? || link.click }
|
135
|
+
expect(browser.h1(text: 'User administration')).to exist
|
135
136
|
end
|
136
137
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
138
|
+
it 'finds an existing link by (index: Integer) and clicks it' do
|
139
|
+
element = browser.link(index: 2)
|
140
|
+
element.wait_until { |link| !link.exist? || link.click }
|
141
|
+
expect(browser.h1(text: 'User administration')).to exist
|
142
142
|
end
|
143
143
|
|
144
144
|
it "raises an UnknownObjectException if the link doesn't exist" do
|
145
145
|
expect { browser.link(index: 1337).click }.to raise_unknown_object_exception
|
146
146
|
end
|
147
147
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
end
|
148
|
+
it 'clicks a link with no text content but an img child',
|
149
|
+
except: {browser: :safari, reason: 'Safari throws a not interactable error'} do
|
150
|
+
browser.goto WatirSpec.url_for('images.html')
|
151
|
+
browser.link(href: /definition_lists.html/).click
|
152
|
+
browser.wait_while(title: /^(Images|)$/)
|
153
|
+
expect(browser.title).to eq 'definition_lists'
|
155
154
|
end
|
156
155
|
end
|
157
156
|
|
@@ -167,14 +166,13 @@ describe 'Link' do
|
|
167
166
|
expect(browser.link(visible_text: /Link 2/, class: 'external')).to exist
|
168
167
|
end
|
169
168
|
|
170
|
-
|
171
|
-
|
172
|
-
|
169
|
+
it 'finds links in spite of hidden text',
|
170
|
+
except: {browser: :safari, reason: 'Safari is not filtering out hidden text'} do
|
171
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
173
172
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
end
|
173
|
+
expect(browser.link(visible_text: 'some visible')).to exist
|
174
|
+
expect(browser.link(visible_text: 'none visible')).not_to exist
|
175
|
+
expect(browser.link(visible_text: /none visible/)).not_to exist
|
178
176
|
end
|
179
177
|
|
180
178
|
it 'raises exception unless value is a String or a RegExp' do
|
@@ -49,15 +49,14 @@ describe 'Links' do
|
|
49
49
|
expect(container.links(visible_text: /some visible/).count).to eq(1)
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
52
|
+
it 'finds links in spite of hidden text',
|
53
|
+
except: {browser: :safari, reason: 'Safari is not filtering out hidden text'} do
|
54
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
55
|
+
container = browser.div(id: 'visible_text')
|
56
|
+
|
57
|
+
expect(container.divs(visible_text: 'some visible').count).to eq(1)
|
58
|
+
expect(container.divs(visible_text: 'none visible').count).to eq(0)
|
59
|
+
expect(container.divs(visible_text: /none visible/).count).to eq(0)
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
@@ -205,20 +205,17 @@ describe 'Radio' do
|
|
205
205
|
expect(messages).to eq ['clicked: new_user_newsletter_no', 'clicked: new_user_newsletter_yes']
|
206
206
|
end
|
207
207
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
list = ['changed: new_user_newsletter', 'clicked: new_user_newsletter_yes', 'changed: new_user_newsletter']
|
220
|
-
expect(messages).to eq list
|
221
|
-
end
|
208
|
+
it 'fires the onchange event' do
|
209
|
+
browser.radio(value: 'certainly').set
|
210
|
+
expect(messages).to eq ['changed: new_user_newsletter']
|
211
|
+
|
212
|
+
browser.radio(value: 'certainly').set
|
213
|
+
expect(messages).to eq ['changed: new_user_newsletter'] # no event fired here - didn't change
|
214
|
+
|
215
|
+
browser.radio(value: 'yes').set
|
216
|
+
browser.radio(value: 'certainly').set
|
217
|
+
list = ['changed: new_user_newsletter', 'clicked: new_user_newsletter_yes', 'changed: new_user_newsletter']
|
218
|
+
expect(messages).to eq list
|
222
219
|
end
|
223
220
|
|
224
221
|
it "raises UnknownObjectException if the radio button doesn't exist" do
|
@@ -220,107 +220,192 @@ describe 'SelectList' do
|
|
220
220
|
end
|
221
221
|
|
222
222
|
describe '#selected?' do
|
223
|
-
it '
|
224
|
-
browser.select_list(name: 'new_user_country').select('
|
223
|
+
it 'evaluates true by text' do
|
224
|
+
browser.select_list(name: 'new_user_country').select('1')
|
225
225
|
expect(browser.select_list(name: 'new_user_country')).to be_selected('Denmark')
|
226
226
|
end
|
227
227
|
|
228
|
-
it '
|
228
|
+
it 'evaluates false by text' do
|
229
229
|
expect(browser.select_list(name: 'new_user_country')).to_not be_selected('Sweden')
|
230
230
|
end
|
231
231
|
|
232
|
-
it '
|
232
|
+
it 'evaluates true exclusively by text' do
|
233
|
+
browser.select_list(name: 'new_user_country').select('1')
|
234
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected(text: 'Denmark')
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'evaluates false exclusively by text' do
|
238
|
+
expect(browser.select_list(name: 'new_user_country')).to_not be_selected(text: 'Sweden')
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'evaluates true by label' do
|
233
242
|
browser.select_list(name: 'new_user_country').select('Germany')
|
234
243
|
expect(browser.select_list(name: 'new_user_country')).to be_selected('Germany')
|
235
244
|
end
|
236
245
|
|
237
|
-
it '
|
246
|
+
it 'evaluates false by label' do
|
238
247
|
expect(browser.select_list(name: 'new_user_country')).to_not be_selected('Germany')
|
239
248
|
end
|
240
249
|
|
241
|
-
it
|
250
|
+
it 'evaluates true exclusively by label' do
|
251
|
+
browser.select_list(name: 'new_user_country').select('Germany')
|
252
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected(label: 'Germany')
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'evaluates false exclusively by label' do
|
256
|
+
expect(browser.select_list(name: 'new_user_country')).to_not be_selected(label: 'Germany')
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'evaluates true by value' do
|
260
|
+
browser.select_list(name: 'new_user_country').select('USA')
|
261
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected('5')
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'evaluates false by value' do
|
265
|
+
expect(browser.select_list(name: 'new_user_country')).to_not be_selected('5')
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'evaluates true exclusively by value' do
|
269
|
+
browser.select_list(name: 'new_user_country').select('USA')
|
270
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected(value: '5')
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'evaluates false exclusively by value' do
|
274
|
+
expect(browser.select_list(name: 'new_user_country')).to_not be_selected(value: '5')
|
275
|
+
end
|
276
|
+
|
277
|
+
it "raises NoValueFoundException if the option doesn't exist" do
|
242
278
|
expect { browser.select_list(name: 'new_user_country').selected?('missing_option') }
|
243
|
-
.to
|
279
|
+
.to raise_no_value_found_exception
|
244
280
|
end
|
245
281
|
end
|
246
282
|
|
247
|
-
describe '#select' do
|
248
|
-
context '
|
249
|
-
|
250
|
-
browser.select_list(name: 'new_user_languages')
|
251
|
-
|
252
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[EN]
|
283
|
+
describe '#select method' do
|
284
|
+
context 'working with multiple select list' do
|
285
|
+
before do
|
286
|
+
@select_list = browser.select_list(name: 'new_user_languages')
|
287
|
+
@select_list.clear
|
253
288
|
end
|
254
289
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
290
|
+
context 'when finding by value' do
|
291
|
+
it 'selects an option with a String' do
|
292
|
+
@select_list.select('2')
|
293
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'selects an option with a Number' do
|
297
|
+
@select_list.select(2)
|
298
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
299
|
+
end
|
300
|
+
|
301
|
+
it 'selects an option with a Regexp' do
|
302
|
+
@select_list.select(/2|3/)
|
303
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'uses keyword with a String' do
|
307
|
+
@select_list.select(value: '2')
|
308
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'uses keyword with a Number' do
|
312
|
+
@select_list.select(value: 2)
|
313
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
314
|
+
end
|
315
|
+
|
316
|
+
it 'uses keyword with a Regexp' do
|
317
|
+
@select_list.select(value: /2|3/)
|
318
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
319
|
+
end
|
259
320
|
end
|
260
|
-
end
|
261
321
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
322
|
+
context 'when finding by text' do
|
323
|
+
it 'selects an option with a String' do
|
324
|
+
@select_list.select('Norwegian')
|
325
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'selects an option with a Regexp' do
|
329
|
+
@select_list.select(/wegia/)
|
330
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'uses keyword with a String' do
|
334
|
+
@select_list.select(text: 'Norwegian')
|
335
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'uses keyword with a Regexp' do
|
339
|
+
@select_list.select(text: /wegia/)
|
340
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
341
|
+
end
|
266
342
|
end
|
267
343
|
|
268
|
-
|
269
|
-
|
270
|
-
|
344
|
+
context 'when finding by label' do
|
345
|
+
it 'selects an option with a String' do
|
346
|
+
@select_list.select('NO')
|
347
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'selects an option with a Regexp' do
|
351
|
+
@select_list.select(/^N/)
|
352
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'uses keyword with a String' do
|
356
|
+
@select_list.select(label: 'NO')
|
357
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
358
|
+
end
|
359
|
+
|
360
|
+
it 'uses keyword with a Regexp' do
|
361
|
+
@select_list.select(label: /^N/)
|
362
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
363
|
+
end
|
271
364
|
end
|
272
|
-
end
|
273
365
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq ['NO']
|
366
|
+
it 'selects multiple options successively' do
|
367
|
+
@select_list.select('Danish')
|
368
|
+
@select_list.select('Swedish')
|
369
|
+
expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
|
279
370
|
end
|
280
371
|
|
281
|
-
it 'selects
|
282
|
-
|
283
|
-
|
284
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq ['NO']
|
372
|
+
it 'selects each item in an Array' do
|
373
|
+
@select_list.select(%w[Danish Swedish])
|
374
|
+
expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
|
285
375
|
end
|
286
|
-
end
|
287
376
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
293
|
-
end
|
377
|
+
it 'selects each item in a parameter list' do
|
378
|
+
@select_list.select('Danish', 'Swedish')
|
379
|
+
expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
|
380
|
+
end
|
294
381
|
|
295
|
-
|
296
|
-
|
382
|
+
it 'selects empty options',
|
383
|
+
except: {browser: :safari, reason: 'Safari throwing ElementNotInteractableError'} do
|
297
384
|
browser.select_list(id: 'delete_user_username').select('')
|
298
385
|
expect(browser.select_list(id: 'delete_user_username').selected_options.map(&:text)).to eq ['']
|
299
386
|
end
|
300
|
-
end
|
301
387
|
|
302
|
-
|
303
|
-
|
304
|
-
|
388
|
+
it 'returns the value selected' do
|
389
|
+
expect(@select_list.select('Danish')).to eq 'Danish'
|
390
|
+
end
|
305
391
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
392
|
+
it 'fires onchange event when selecting or deselecting an item' do
|
393
|
+
@select_list.select('Danish')
|
394
|
+
expect(messages).to eq ['changed language', 'changed language', 'changed language']
|
395
|
+
end
|
310
396
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
expect(messages.size).to eq 3
|
397
|
+
it "doesn't fire onchange event when selecting an already selected item" do
|
398
|
+
@select_list.select('English')
|
399
|
+
expect(messages.size).to eq 3
|
315
400
|
|
316
|
-
|
317
|
-
|
401
|
+
@select_list.select('English')
|
402
|
+
expect(messages.size).to eq 3
|
403
|
+
end
|
318
404
|
end
|
319
405
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
end
|
406
|
+
it 'returns an empty string when selecting an option that disappears when selected',
|
407
|
+
except: {browser: :safari, reason: 'Safari throwing ElementNotInteractableError'} do
|
408
|
+
expect(browser.select_list(id: 'obsolete').select('sweden')).to eq ''
|
324
409
|
end
|
325
410
|
|
326
411
|
it 'selects options with a single-quoted value' do
|
@@ -342,15 +427,13 @@ describe 'SelectList' do
|
|
342
427
|
.to raise_no_value_found_exception message
|
343
428
|
end
|
344
429
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
.to raise_object_disabled_exception
|
349
|
-
end
|
430
|
+
it 'raises ObjectDisabledException if the option is disabled', except: {browser: :safari} do
|
431
|
+
expect { browser.select_list(name: 'new_user_languages').select('Russian') }
|
432
|
+
.to raise_object_disabled_exception
|
350
433
|
end
|
351
434
|
|
352
435
|
it 'raises a TypeError if argument is not a String, Regexp or Numeric' do
|
353
|
-
expect { browser.select_list(id: 'new_user_languages').select(
|
436
|
+
expect { browser.select_list(id: 'new_user_languages').select(true) }.to raise_error(TypeError)
|
354
437
|
end
|
355
438
|
|
356
439
|
context 'multiple options' do
|
@@ -408,61 +491,112 @@ describe 'SelectList' do
|
|
408
491
|
end
|
409
492
|
|
410
493
|
describe '#select!' do
|
411
|
-
context '
|
412
|
-
|
413
|
-
browser.select_list(name: 'new_user_languages')
|
414
|
-
|
415
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[EN]
|
494
|
+
context 'working with multiple select list' do
|
495
|
+
before do
|
496
|
+
@select_list = browser.select_list(name: 'new_user_languages')
|
497
|
+
@select_list.clear
|
416
498
|
end
|
417
499
|
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
500
|
+
context 'when finding by value' do
|
501
|
+
it 'selects an option with a String' do
|
502
|
+
@select_list.select!('2')
|
503
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
504
|
+
end
|
505
|
+
|
506
|
+
it 'selects an option with a Number' do
|
507
|
+
@select_list.select!(2)
|
508
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
509
|
+
end
|
510
|
+
|
511
|
+
it 'selects an option with a Regexp' do
|
512
|
+
@select_list.select!(/2|3/)
|
513
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
514
|
+
end
|
515
|
+
|
516
|
+
it 'uses keyword with a String' do
|
517
|
+
@select_list.select!(value: '2')
|
518
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
519
|
+
end
|
520
|
+
|
521
|
+
it 'uses keyword with a Number' do
|
522
|
+
@select_list.select!(value: 2)
|
523
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
524
|
+
end
|
525
|
+
|
526
|
+
it 'uses keyword with a Regexp' do
|
527
|
+
@select_list.select!(value: /2|3/)
|
528
|
+
expect(@select_list.selected_options.first.text).to eq 'EN'
|
529
|
+
end
|
422
530
|
end
|
423
|
-
end
|
424
531
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
532
|
+
context 'when finding by text' do
|
533
|
+
it 'selects an option with a String' do
|
534
|
+
@select_list.select!('Danish')
|
535
|
+
expect(@select_list.selected_options.first.value).to eq '1'
|
536
|
+
end
|
537
|
+
|
538
|
+
it 'selects an option with a Regexp' do
|
539
|
+
@select_list.select!(/ani/)
|
540
|
+
expect(@select_list.selected_options.first.value).to eq '1'
|
541
|
+
end
|
542
|
+
|
543
|
+
it 'uses keyword with a String' do
|
544
|
+
@select_list.select!(text: 'Danish')
|
545
|
+
expect(@select_list.selected_options.first.value).to eq '1'
|
546
|
+
end
|
547
|
+
|
548
|
+
it 'uses keyword with a Regexp' do
|
549
|
+
@select_list.select!(text: /ani/)
|
550
|
+
expect(@select_list.selected_options.first.value).to eq '1'
|
551
|
+
end
|
429
552
|
end
|
430
553
|
|
431
|
-
|
432
|
-
|
433
|
-
|
554
|
+
context 'when finding by label' do
|
555
|
+
it 'selects an option with a String' do
|
556
|
+
@select_list.select!('NO')
|
557
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
558
|
+
end
|
559
|
+
|
560
|
+
it 'selects an option with a Regexp' do
|
561
|
+
@select_list.select!(/^N/)
|
562
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
563
|
+
end
|
564
|
+
|
565
|
+
it 'uses keyword with a String' do
|
566
|
+
@select_list.select!(label: 'NO')
|
567
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
568
|
+
end
|
569
|
+
|
570
|
+
it 'uses keyword with a Regexp' do
|
571
|
+
@select_list.select!(label: /^N/)
|
572
|
+
expect(@select_list.selected_options.first.value).to eq '3'
|
573
|
+
end
|
434
574
|
end
|
435
|
-
end
|
436
575
|
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq ['NO']
|
576
|
+
it 'selects multiple options successively' do
|
577
|
+
@select_list.select!('Danish')
|
578
|
+
@select_list.select!('Swedish')
|
579
|
+
expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
|
442
580
|
end
|
443
581
|
|
444
|
-
it 'selects
|
445
|
-
|
446
|
-
|
447
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq ['NO']
|
582
|
+
it 'selects each item in an Array' do
|
583
|
+
@select_list.select!(%w[Danish Swedish])
|
584
|
+
expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
|
448
585
|
end
|
449
|
-
end
|
450
586
|
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
456
|
-
end
|
587
|
+
it 'selects each item in a parameter list' do
|
588
|
+
@select_list.select!('Danish', 'Swedish')
|
589
|
+
expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
|
590
|
+
end
|
457
591
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
592
|
+
it 'selects empty options' do
|
593
|
+
browser.select_list(id: 'delete_user_username').select!('')
|
594
|
+
expect(browser.select_list(id: 'delete_user_username').selected_options.map(&:text)).to eq ['']
|
595
|
+
end
|
462
596
|
|
463
|
-
|
464
|
-
|
465
|
-
|
597
|
+
it 'returns the value selected' do
|
598
|
+
expect(@select_list.select!('Danish')).to eq 'Danish'
|
599
|
+
end
|
466
600
|
end
|
467
601
|
|
468
602
|
it 'selects options with a single-quoted value' do
|
@@ -484,17 +618,14 @@ describe 'SelectList' do
|
|
484
618
|
.to raise_no_value_found_exception
|
485
619
|
end
|
486
620
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
.to raise_object_disabled_exception
|
492
|
-
end
|
621
|
+
it 'raises ObjectDisabledException if the option is disabled', except: {browser: :safari} do
|
622
|
+
browser.select_list(id: 'new_user_languages').clear
|
623
|
+
expect { browser.select_list(name: 'new_user_languages').select!('Russian') }
|
624
|
+
.to raise_object_disabled_exception
|
493
625
|
end
|
494
626
|
|
495
627
|
it 'raises a TypeError if argument is not a String, Regexp or Numeric' do
|
496
|
-
browser.select_list(id: 'new_user_languages').
|
497
|
-
expect { browser.select_list(id: 'new_user_languages').select!({}) }.to raise_error(TypeError)
|
628
|
+
expect { browser.select_list(id: 'new_user_languages').select!(true) }.to raise_error(TypeError)
|
498
629
|
end
|
499
630
|
|
500
631
|
context 'multiple options' do
|