watir 6.17.0 → 6.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/actions/enable-safari/action.yml +11 -0
- data/.github/actions/install-chrome/action.yml +11 -0
- data/.github/workflows/linux.yml +61 -0
- data/.github/workflows/mac.yml +55 -0
- data/.github/workflows/unit.yml +31 -0
- data/.github/workflows/windows.yml +39 -0
- data/.rubocop_todo.yml +36 -0
- data/CHANGES.md +14 -0
- data/LICENSE +2 -2
- data/README.md +9 -10
- data/Rakefile +1 -1
- data/lib/watir.rb +1 -0
- data/lib/watir/adjacent.rb +1 -1
- data/lib/watir/alert.rb +1 -0
- data/lib/watir/attribute_helper.rb +2 -0
- data/lib/watir/browser.rb +2 -2
- data/lib/watir/cookies.rb +2 -0
- data/lib/watir/element_collection.rb +21 -6
- data/lib/watir/elements/element.rb +10 -10
- data/lib/watir/elements/html_elements.rb +0 -1
- data/lib/watir/elements/iframe.rb +2 -1
- data/lib/watir/elements/select.rb +20 -5
- data/lib/watir/generator/html/generator.rb +1 -1
- data/lib/watir/has_window.rb +17 -15
- data/lib/watir/js_execution.rb +2 -2
- data/lib/watir/js_snippets.rb +2 -2
- data/lib/watir/locators.rb +1 -3
- data/lib/watir/locators/element/selector_builder.rb +1 -1
- data/lib/watir/logger.rb +2 -18
- data/lib/watir/radio_set.rb +2 -2
- data/lib/watir/user_editable.rb +6 -2
- data/lib/watir/version.rb +1 -1
- data/lib/watir/wait.rb +2 -0
- data/lib/watir/wait/timer.rb +1 -1
- data/lib/watir/window.rb +7 -3
- data/lib/watir/window_collection.rb +105 -0
- data/lib/watirspec.rb +1 -0
- data/lib/watirspec/implementation.rb +3 -5
- data/lib/watirspec/runner.rb +1 -1
- data/lib/watirspec/server.rb +1 -1
- data/spec/spec_helper.rb +2 -7
- data/spec/unit/match_elements/element_spec.rb +17 -15
- data/spec/unit/unit_helper.rb +2 -4
- data/spec/watirspec/after_hooks_spec.rb +15 -11
- data/spec/watirspec/browser_spec.rb +3 -2
- data/spec/watirspec/elements/element_spec.rb +14 -11
- data/spec/watirspec/elements/filefield_spec.rb +2 -2
- data/spec/watirspec/elements/iframe_spec.rb +5 -7
- data/spec/watirspec/elements/link_spec.rb +5 -3
- data/spec/watirspec/elements/select_list_spec.rb +156 -37
- data/spec/watirspec/html/wait.html +5 -5
- data/spec/watirspec/html/window_switching.html +10 -0
- data/spec/watirspec/legacy_wait_spec.rb +216 -0
- data/spec/watirspec/support/rspec_matchers.rb +10 -7
- data/spec/watirspec/wait_spec.rb +257 -301
- data/spec/watirspec/window_switching_spec.rb +282 -160
- data/spec/watirspec_helper.rb +10 -15
- data/support/doctest_helper.rb +0 -2
- data/watir.gemspec +2 -2
- metadata +25 -13
- data/.travis.yml +0 -87
- data/appveyor.yml +0 -13
- data/spec/watirspec/relaxed_locate_spec.rb +0 -109
data/lib/watirspec.rb
CHANGED
@@ -77,6 +77,7 @@ module WatirSpec
|
|
77
77
|
|
78
78
|
info << caps.browser_name.to_s
|
79
79
|
info << caps.version.to_s
|
80
|
+
info << @implementation.driver_info
|
80
81
|
|
81
82
|
Watir.logger.warn "running watirspec against #{info.join ' '} using:\n#{WatirSpec.implementation.inspect_args}",
|
82
83
|
ids: [:browser_info]
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module WatirSpec
|
2
2
|
class Implementation
|
3
3
|
attr_writer :name, :guard_proc, :browser_class
|
4
|
-
attr_accessor :browser_args
|
4
|
+
attr_accessor :browser_args, :driver_info
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@guard_proc = nil
|
8
8
|
end
|
9
9
|
|
10
|
-
def initialize_copy(
|
11
|
-
|
12
|
-
# Backward compatibility < Ruby 2.4
|
13
|
-
@browser_args = browser_args.map { |arg| arg.is_a?(Symbol) ? arg : arg.dup }
|
10
|
+
def initialize_copy(_orig)
|
11
|
+
@browser_args = browser_args.map(&:dup)
|
14
12
|
end
|
15
13
|
|
16
14
|
def browser_class
|
data/lib/watirspec/runner.rb
CHANGED
data/lib/watirspec/server.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
|
4
|
-
if ENV['
|
4
|
+
if ENV['GITHUB_ACTIONS'] || ENV['COVERAGE']
|
5
5
|
require 'coveralls'
|
6
6
|
require 'simplecov'
|
7
7
|
require 'simplecov-console'
|
@@ -19,11 +19,10 @@ if ENV['TRAVIS'] || ENV['COVERAGE']
|
|
19
19
|
end
|
20
20
|
|
21
21
|
require 'watir'
|
22
|
-
require 'webdrivers'
|
23
22
|
require 'locator_spec_helper'
|
24
23
|
require 'rspec'
|
25
24
|
|
26
|
-
if ENV['
|
25
|
+
if ENV['GITHUB_ACTIONS']
|
27
26
|
require 'rspec/retry'
|
28
27
|
RSpec.configure do |config|
|
29
28
|
config.verbose_retry = true
|
@@ -36,7 +35,3 @@ end
|
|
36
35
|
SELENIUM_SELECTORS = %i[css tag_name xpath link_text partial_link_text link].freeze
|
37
36
|
|
38
37
|
Watir.relaxed_locate = false if ENV['RELAXED_LOCATE'] == 'false'
|
39
|
-
|
40
|
-
ENV['DISPLAY'] = ':99.0' if ENV['TRAVIS']
|
41
|
-
|
42
|
-
raise 'DISPLAY not set' if Selenium::WebDriver::Platform.linux? && ENV['DISPLAY'].nil?
|
@@ -377,6 +377,8 @@ describe Watir::Locators::Element::Matcher do
|
|
377
377
|
it 'not thrown when still matched by text content' do
|
378
378
|
@values_to_match = {text: /some visible/}
|
379
379
|
allow(browser).to receive(:execute_script).and_return('some visible some hidden')
|
380
|
+
allow(browser).to receive(:timer).and_return(Watir::Wait::Timer.new)
|
381
|
+
allow(browser).to receive(:timer=).and_return(Watir::Wait::Timer.new)
|
380
382
|
|
381
383
|
expect {
|
382
384
|
expect(matcher.match(elements, values_to_match, filter)).to eq elements[1]
|
@@ -386,31 +388,31 @@ describe Watir::Locators::Element::Matcher do
|
|
386
388
|
it 'not thrown with complex regexp matched by text content' do
|
387
389
|
@values_to_match = {text: /some (in|)visible/}
|
388
390
|
allow(browser).to receive(:execute_script).and_return('some visible some hidden')
|
391
|
+
allow(browser).to receive(:timer).and_return(Watir::Wait::Timer.new)
|
392
|
+
allow(browser).to receive(:timer=).and_return(Watir::Wait::Timer.new)
|
389
393
|
|
390
394
|
expect {
|
391
395
|
expect(matcher.match(elements, values_to_match, filter)).to eq elements[1]
|
392
396
|
}.not_to have_deprecated_text_regexp
|
393
397
|
end
|
394
398
|
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
+
it 'thrown when no longer matched by text content' do
|
400
|
+
@values_to_match = {text: /some visible$/}
|
401
|
+
allow(browser).to receive(:execute_script).and_return('some visible some hidden')
|
402
|
+
allow(browser).to receive(:timer).and_return(Watir::Wait::Timer.new)
|
403
|
+
allow(browser).to receive(:timer=).and_return(Watir::Wait::Timer.new)
|
399
404
|
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
end
|
405
|
+
expect {
|
406
|
+
expect(matcher.match(elements, values_to_match, filter)).to eq elements[1]
|
407
|
+
}.to have_deprecated_text_regexp
|
404
408
|
end
|
405
409
|
|
406
|
-
|
407
|
-
|
408
|
-
@values_to_match = {text: /definitely not there/}
|
410
|
+
it 'not thrown when element does not exist' do
|
411
|
+
@values_to_match = {text: /definitely not there/}
|
409
412
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
end
|
413
|
+
expect {
|
414
|
+
expect(matcher.match(elements, values_to_match, filter)).to eq elements[1]
|
415
|
+
}.to_not have_deprecated_text_regexp
|
414
416
|
end
|
415
417
|
|
416
418
|
# Note: This will work after:text_regexp deprecation removed
|
data/spec/unit/unit_helper.rb
CHANGED
@@ -50,6 +50,8 @@ describe 'Browser::AfterHooks' do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
describe '#run' do
|
53
|
+
before { @yield = nil }
|
54
|
+
|
53
55
|
after(:each) do
|
54
56
|
browser.original_window.use
|
55
57
|
browser.after_hooks.delete @page_after_hook
|
@@ -186,17 +188,19 @@ describe 'Browser::AfterHooks' do
|
|
186
188
|
end
|
187
189
|
|
188
190
|
bug 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException', :safari do
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
191
|
+
bug 'https://github.com/mozilla/geckodriver/issues/1847', :firefox do
|
192
|
+
it 'does not raise error when running error checks on closed window' do
|
193
|
+
url = WatirSpec.url_for('window_switching.html')
|
194
|
+
@page_after_hook = proc { browser.url }
|
195
|
+
browser.after_hooks.add @page_after_hook
|
196
|
+
browser.goto url
|
197
|
+
browser.a(id: 'open').click
|
198
|
+
|
199
|
+
window = browser.window(title: 'closeable window')
|
200
|
+
window.use
|
201
|
+
expect { browser.a(id: 'close').click }.to_not raise_error
|
202
|
+
browser.original_window.use
|
203
|
+
end
|
200
204
|
end
|
201
205
|
end
|
202
206
|
end
|
@@ -148,8 +148,9 @@ describe 'Browser' do
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
-
|
152
|
-
|
151
|
+
# TODO: Temporarily disabling this before moving it to unit tests
|
152
|
+
xdescribe '#new' do
|
153
|
+
not_compliant_on :remote do
|
153
154
|
context 'with parameters' do
|
154
155
|
let(:url) { 'http://localhost:4544/wd/hub/' }
|
155
156
|
|
@@ -709,10 +709,13 @@ describe 'Element' do
|
|
709
709
|
describe '#size' do
|
710
710
|
it 'returns size of element' do
|
711
711
|
size = browser.button(name: 'new_user_image').size
|
712
|
-
|
713
712
|
expect(size).to be_a Selenium::WebDriver::Dimension
|
714
|
-
|
715
|
-
|
713
|
+
|
714
|
+
expected_width = browser.name == :safari ? 105 : 104
|
715
|
+
expected_height = browser.name == :safari ? 71 : 70
|
716
|
+
|
717
|
+
expect(size['width']).to eq expected_width
|
718
|
+
expect(size['height']).to eq expected_height
|
716
719
|
end
|
717
720
|
end
|
718
721
|
|
@@ -720,7 +723,8 @@ describe 'Element' do
|
|
720
723
|
it 'returns height of element' do
|
721
724
|
height = browser.button(name: 'new_user_image').height
|
722
725
|
|
723
|
-
|
726
|
+
expected_height = browser.name == :safari ? 71 : 70
|
727
|
+
expect(height).to eq expected_height
|
724
728
|
end
|
725
729
|
end
|
726
730
|
|
@@ -728,7 +732,8 @@ describe 'Element' do
|
|
728
732
|
it 'returns width of element' do
|
729
733
|
width = browser.button(name: 'new_user_image').width
|
730
734
|
|
731
|
-
|
735
|
+
expected_width = browser.name == :safari ? 105 : 104
|
736
|
+
expect(width).to eq expected_width
|
732
737
|
end
|
733
738
|
end
|
734
739
|
|
@@ -905,12 +910,10 @@ describe 'Element' do
|
|
905
910
|
end
|
906
911
|
end
|
907
912
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
expect { btn.click }.not_to raise_exception
|
913
|
-
end
|
913
|
+
it 'returns false if element center is surrounded by non-descendants' do
|
914
|
+
btn = browser.button(id: 'surrounded')
|
915
|
+
expect(btn).not_to be_obscured
|
916
|
+
expect { btn.click }.not_to raise_exception
|
914
917
|
end
|
915
918
|
|
916
919
|
it 'scrolls interactive element into view before checking if obscured' do
|
@@ -124,9 +124,9 @@ describe 'FileField' do
|
|
124
124
|
|
125
125
|
not_compliant_on :internet_explorer, %i[chrome windows] do
|
126
126
|
it 'does not alter its argument' do
|
127
|
-
value = File.expand_path '.
|
127
|
+
value = File.expand_path '.rubocop.yml'
|
128
128
|
browser.file_field.value = value
|
129
|
-
expect(value).to match(/\.
|
129
|
+
expect(value).to match(/\.rubocop\.yml$/)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
@@ -11,7 +11,7 @@ describe 'IFrame' do
|
|
11
11
|
|
12
12
|
not_compliant_on :safari do
|
13
13
|
bug 'Firefox 58 broke this, appears to be working in Nightly',
|
14
|
-
%i[firefox linux]
|
14
|
+
%i[firefox linux] do
|
15
15
|
it 'handles crossframe javascript' do
|
16
16
|
browser.goto WatirSpec.url_for('iframes.html')
|
17
17
|
|
@@ -144,12 +144,10 @@ describe 'IFrame' do
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
browser.h1.text
|
152
|
-
end
|
147
|
+
it 'switches between iframe and parent when needed' do
|
148
|
+
browser.iframe(id: 'iframe_1').elements.each do |element|
|
149
|
+
element.text
|
150
|
+
browser.h1.text
|
153
151
|
end
|
154
152
|
end
|
155
153
|
|
@@ -134,9 +134,11 @@ describe 'Link' do
|
|
134
134
|
expect(browser.text.include?('User administration')).to be true
|
135
135
|
end
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
bug 'sometimes safari does not work on the first click', :safari do
|
138
|
+
it 'finds an existing link by (index: Integer) and clicks it' do
|
139
|
+
browser.link(index: 2).click
|
140
|
+
expect(browser.text.include?('User administration')).to be true
|
141
|
+
end
|
140
142
|
end
|
141
143
|
|
142
144
|
it "raises an UnknownObjectException if the link doesn't exist" do
|
@@ -81,6 +81,19 @@ describe 'SelectList' do
|
|
81
81
|
expect(browser.select_list(index: 0).value).to eq '3'
|
82
82
|
end
|
83
83
|
|
84
|
+
it 'returns the value of the selected options' do
|
85
|
+
browser.select_list(name: 'new_user_languages').select('1')
|
86
|
+
expect(browser.select_list(name: 'new_user_languages').value).to eq '1'
|
87
|
+
browser.select_list(name: 'new_user_languages').clear
|
88
|
+
browser.select_list(name: 'new_user_languages').select('NO')
|
89
|
+
expect(browser.select_list(name: 'new_user_languages').value).to eq '3'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'returns null when no values selected' do
|
93
|
+
browser.select_list(name: 'new_user_languages').clear
|
94
|
+
expect(browser.select_list(name: 'new_user_languages').value).to be_nil
|
95
|
+
end
|
96
|
+
|
84
97
|
it "raises UnknownObjectException if the select list doesn't exist" do
|
85
98
|
expect { browser.select_list(index: 1337).value }.to raise_unknown_object_exception
|
86
99
|
end
|
@@ -241,7 +254,9 @@ describe 'SelectList' do
|
|
241
254
|
|
242
255
|
it 'selects an option with a Regexp' do
|
243
256
|
browser.select_list(name: 'new_user_languages').clear
|
244
|
-
expect {
|
257
|
+
expect {
|
258
|
+
browser.select_list(name: 'new_user_languages').select(/1|3/)
|
259
|
+
}.to have_deprecated_select_by
|
245
260
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish NO]
|
246
261
|
end
|
247
262
|
end
|
@@ -272,25 +287,13 @@ describe 'SelectList' do
|
|
272
287
|
end
|
273
288
|
end
|
274
289
|
|
275
|
-
it 'selects multiple options
|
290
|
+
it 'selects multiple options successively' do
|
276
291
|
browser.select_list(name: 'new_user_languages').clear
|
277
292
|
browser.select_list(name: 'new_user_languages').select('Danish')
|
278
293
|
browser.select_list(name: 'new_user_languages').select('Swedish')
|
279
294
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
280
295
|
end
|
281
296
|
|
282
|
-
it 'selects each item in an Array' do
|
283
|
-
browser.select_list(name: 'new_user_languages').clear
|
284
|
-
browser.select_list(name: 'new_user_languages').select(%w[Danish Swedish])
|
285
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
286
|
-
end
|
287
|
-
|
288
|
-
it 'selects each item in a parameter list' do
|
289
|
-
browser.select_list(name: 'new_user_languages').clear
|
290
|
-
browser.select_list(name: 'new_user_languages').select('Danish', 'Swedish')
|
291
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
292
|
-
end
|
293
|
-
|
294
297
|
bug 'Safari is returning click intercepted error', :safari do
|
295
298
|
it 'selects empty options' do
|
296
299
|
browser.select_list(id: 'delete_user_username').select('')
|
@@ -353,6 +356,59 @@ describe 'SelectList' do
|
|
353
356
|
it 'raises a TypeError if argument is not a String, Regexp or Numeric' do
|
354
357
|
expect { browser.select_list(id: 'new_user_languages').select({}) }.to raise_error(TypeError)
|
355
358
|
end
|
359
|
+
|
360
|
+
context 'multiple options' do
|
361
|
+
it 'in an Array' do
|
362
|
+
browser.select_list(name: 'new_user_languages').clear
|
363
|
+
browser.select_list(name: 'new_user_languages').select(%w[Danish Swedish])
|
364
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'in a parameter list' do
|
368
|
+
browser.select_list(name: 'new_user_languages').clear
|
369
|
+
browser.select_list(name: 'new_user_languages').select('Danish', 'Swedish')
|
370
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
371
|
+
end
|
372
|
+
|
373
|
+
it 'based on text' do
|
374
|
+
browser.select_list(name: 'new_user_languages').clear
|
375
|
+
browser.select_list(name: 'new_user_languages').select([/ish/])
|
376
|
+
list = %w[Danish EN Swedish]
|
377
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'based on label and single regexp' do
|
381
|
+
browser.select_list(name: 'new_user_languages').clear
|
382
|
+
browser.select_list(name: 'new_user_languages').select([/NO|EN/])
|
383
|
+
list = %w[EN NO]
|
384
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
385
|
+
end
|
386
|
+
|
387
|
+
it 'based on label and multiple regexp' do
|
388
|
+
browser.select_list(name: 'new_user_languages').clear
|
389
|
+
browser.select_list(name: 'new_user_languages').select([/NO/, /EN/])
|
390
|
+
list = %w[EN NO]
|
391
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
392
|
+
end
|
393
|
+
|
394
|
+
it 'from an Array' do
|
395
|
+
browser.select_list(name: 'new_user_languages').clear
|
396
|
+
browser.select_list(name: 'new_user_languages').select([/ish/, /Latin/])
|
397
|
+
list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
|
398
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
399
|
+
end
|
400
|
+
|
401
|
+
it 'from multiple arguments' do
|
402
|
+
browser.select_list(name: 'new_user_languages').clear
|
403
|
+
browser.select_list(name: 'new_user_languages').select(/ish/, /Latin/)
|
404
|
+
list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
|
405
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
406
|
+
end
|
407
|
+
|
408
|
+
it 'returns the first matching value if there are multiple matches' do
|
409
|
+
expect(browser.select_list(name: 'new_user_languages').select([/ish/])).to eq 'Danish'
|
410
|
+
end
|
411
|
+
end
|
356
412
|
end
|
357
413
|
|
358
414
|
describe '#select!' do
|
@@ -403,18 +459,6 @@ describe 'SelectList' do
|
|
403
459
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
404
460
|
end
|
405
461
|
|
406
|
-
it 'selects each item in an Array' do
|
407
|
-
browser.select_list(name: 'new_user_languages').clear
|
408
|
-
browser.select_list(name: 'new_user_languages').select!(%w[Danish Swedish])
|
409
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
410
|
-
end
|
411
|
-
|
412
|
-
it 'selects each item in a parameter list' do
|
413
|
-
browser.select_list(name: 'new_user_languages').clear
|
414
|
-
browser.select_list(name: 'new_user_languages').select!('Danish', 'Swedish')
|
415
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
416
|
-
end
|
417
|
-
|
418
462
|
it 'selects empty options' do
|
419
463
|
browser.select_list(id: 'delete_user_username').select!('')
|
420
464
|
expect(browser.select_list(id: 'delete_user_username').selected_options.map(&:text)).to eq ['']
|
@@ -456,80 +500,155 @@ describe 'SelectList' do
|
|
456
500
|
browser.select_list(id: 'new_user_languages').clear
|
457
501
|
expect { browser.select_list(id: 'new_user_languages').select!({}) }.to raise_error(TypeError)
|
458
502
|
end
|
503
|
+
|
504
|
+
context 'multiple options' do
|
505
|
+
it 'in an Array' do
|
506
|
+
browser.select_list(name: 'new_user_languages').clear
|
507
|
+
browser.select_list(name: 'new_user_languages').select!(%w[Danish Swedish])
|
508
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
509
|
+
end
|
510
|
+
|
511
|
+
it 'in a parameter list' do
|
512
|
+
browser.select_list(name: 'new_user_languages').clear
|
513
|
+
browser.select_list(name: 'new_user_languages').select!('Danish', 'Swedish')
|
514
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
515
|
+
end
|
516
|
+
|
517
|
+
it 'based on text' do
|
518
|
+
browser.select_list(name: 'new_user_languages').clear
|
519
|
+
browser.select_list(name: 'new_user_languages').select!([/ish/])
|
520
|
+
list = %w[Danish EN Swedish]
|
521
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
522
|
+
end
|
523
|
+
|
524
|
+
it 'based on label and single regexp' do
|
525
|
+
browser.select_list(name: 'new_user_languages').clear
|
526
|
+
browser.select_list(name: 'new_user_languages').select!([/NO|EN/])
|
527
|
+
list = %w[EN NO]
|
528
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
529
|
+
end
|
530
|
+
|
531
|
+
it 'based on label and multiple regexp' do
|
532
|
+
browser.select_list(name: 'new_user_languages').clear
|
533
|
+
browser.select_list(name: 'new_user_languages').select!([/NO/, /EN/])
|
534
|
+
list = %w[EN NO]
|
535
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
536
|
+
end
|
537
|
+
|
538
|
+
it 'from an Array' do
|
539
|
+
browser.select_list(name: 'new_user_languages').clear
|
540
|
+
browser.select_list(name: 'new_user_languages').select!([/ish/, /Latin/])
|
541
|
+
list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
|
542
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
543
|
+
end
|
544
|
+
|
545
|
+
it 'from multiple arguments' do
|
546
|
+
browser.select_list(name: 'new_user_languages').clear
|
547
|
+
browser.select_list(name: 'new_user_languages').select!(/ish/, /Latin/)
|
548
|
+
list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
|
549
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
550
|
+
end
|
551
|
+
|
552
|
+
it 'returns the first matching value if there are multiple matches' do
|
553
|
+
expect(browser.select_list(name: 'new_user_languages').select!([/ish/])).to eq 'Danish'
|
554
|
+
end
|
555
|
+
end
|
459
556
|
end
|
460
557
|
|
461
558
|
describe '#select_all' do
|
462
559
|
it 'selects multiple options based on text' do
|
463
560
|
browser.select_list(name: 'new_user_languages').clear
|
464
|
-
|
561
|
+
expect {
|
562
|
+
browser.select_list(name: 'new_user_languages').select_all(/ish/)
|
563
|
+
}.to have_deprecated_select_all
|
465
564
|
list = %w[Danish EN Swedish]
|
466
565
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
467
566
|
end
|
468
567
|
|
469
568
|
it 'selects multiple options based on labels' do
|
470
569
|
browser.select_list(name: 'new_user_languages').clear
|
471
|
-
|
570
|
+
expect {
|
571
|
+
browser.select_list(name: 'new_user_languages').select_all(/NO|EN/)
|
572
|
+
}.to have_deprecated_select_all
|
472
573
|
list = %w[EN NO]
|
473
574
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
474
575
|
end
|
475
576
|
|
476
577
|
it 'selects all options in an Array' do
|
477
578
|
browser.select_list(name: 'new_user_languages').clear
|
478
|
-
|
579
|
+
expect {
|
580
|
+
browser.select_list(name: 'new_user_languages').select_all([/ish/, /Latin/])
|
581
|
+
}.to have_deprecated_select_all
|
479
582
|
list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
|
480
583
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
481
584
|
end
|
482
585
|
|
483
586
|
it 'selects all options in a parameter list' do
|
484
587
|
browser.select_list(name: 'new_user_languages').clear
|
485
|
-
|
588
|
+
expect {
|
589
|
+
browser.select_list(name: 'new_user_languages').select_all(/ish/, /Latin/)
|
590
|
+
}.to have_deprecated_select_all
|
486
591
|
list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
|
487
592
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
488
593
|
end
|
489
594
|
|
490
595
|
it 'returns the first matching value if there are multiple matches' do
|
491
|
-
expect
|
596
|
+
expect {
|
597
|
+
expect(browser.select_list(name: 'new_user_languages').select_all(/ish/)).to eq 'Danish'
|
598
|
+
}.to have_deprecated_select_all
|
492
599
|
end
|
493
600
|
end
|
494
601
|
|
495
602
|
describe '#select_all!' do
|
496
603
|
it 'selects multiple options based on value' do
|
497
604
|
browser.select_list(name: 'new_user_languages').clear
|
498
|
-
|
605
|
+
expect {
|
606
|
+
browser.select_list(name: 'new_user_languages').select_all!(/\d+/)
|
607
|
+
}.to have_deprecated_select_all
|
499
608
|
list = %w[Danish EN NO Russian]
|
500
609
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
501
610
|
end
|
502
611
|
|
503
612
|
it 'selects multiple options based on text' do
|
504
613
|
browser.select_list(name: 'new_user_languages').clear
|
505
|
-
|
614
|
+
expect {
|
615
|
+
browser.select_list(name: 'new_user_languages').select_all!(/ish/)
|
616
|
+
}.to have_deprecated_select_all
|
506
617
|
list = %w[Danish EN Swedish]
|
507
618
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
508
619
|
end
|
509
620
|
|
510
621
|
it 'selects multiple options based on labels' do
|
511
622
|
browser.select_list(name: 'new_user_languages').clear
|
512
|
-
|
623
|
+
expect {
|
624
|
+
browser.select_list(name: 'new_user_languages').select_all!(/NO|EN/)
|
625
|
+
}.to have_deprecated_select_all
|
513
626
|
list = %w[EN NO]
|
514
627
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
515
628
|
end
|
516
629
|
|
517
630
|
it 'selects all options in an Array' do
|
518
631
|
browser.select_list(name: 'new_user_languages').clear
|
519
|
-
|
632
|
+
expect {
|
633
|
+
browser.select_list(name: 'new_user_languages').select_all!([/ish/, /Latin/])
|
634
|
+
}.to have_deprecated_select_all
|
520
635
|
list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
|
521
636
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
522
637
|
end
|
523
638
|
|
524
639
|
it 'selects all options in a parameter list' do
|
525
640
|
browser.select_list(name: 'new_user_languages').clear
|
526
|
-
|
641
|
+
expect {
|
642
|
+
browser.select_list(name: 'new_user_languages').select_all!(/ish/, /Latin/)
|
643
|
+
}.to have_deprecated_select_all
|
527
644
|
list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
|
528
645
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
|
529
646
|
end
|
530
647
|
|
531
648
|
it 'returns the first matching value if there are multiple matches' do
|
532
|
-
expect
|
649
|
+
expect {
|
650
|
+
expect(browser.select_list(name: 'new_user_languages').select_all!(/ish/)).to eq 'Danish'
|
651
|
+
}.to have_deprecated_select_all
|
533
652
|
end
|
534
653
|
end
|
535
654
|
end
|