watir 6.7.3 → 6.8.0
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/.travis.yml +2 -0
- data/CHANGES.md +11 -0
- data/lib/watir.rb +4 -1
- data/lib/watir/adjacent.rb +1 -1
- data/lib/watir/browser.rb +5 -3
- data/lib/watir/capabilities.rb +1 -0
- data/lib/watir/container.rb +1 -1
- data/lib/watir/elements/element.rb +31 -98
- data/lib/watir/elements/file_field.rb +1 -1
- data/lib/watir/elements/iframe.rb +1 -1
- data/lib/watir/elements/image.rb +1 -5
- data/lib/watir/elements/input.rb +15 -0
- data/lib/watir/elements/radio.rb +17 -0
- data/lib/watir/elements/select.rb +67 -20
- data/lib/watir/js_execution.rb +141 -0
- data/lib/watir/js_snippets.rb +16 -0
- data/lib/watir/js_snippets/backgroundColor.js +7 -0
- data/lib/watir/{atoms → js_snippets}/fireEvent.js +2 -0
- data/lib/watir/js_snippets/focus.js +3 -0
- data/lib/watir/{atoms → js_snippets}/getInnerHtml.js +1 -0
- data/lib/watir/js_snippets/getInnerText.js +19 -0
- data/lib/watir/{atoms → js_snippets}/getOuterHtml.js +2 -0
- data/lib/watir/js_snippets/getTextContent.js +19 -0
- data/lib/watir/js_snippets/isImageLoaded.js +3 -0
- data/lib/watir/js_snippets/selectOptionsLabel.js +10 -0
- data/lib/watir/js_snippets/selectOptionsText.js +10 -0
- data/lib/watir/js_snippets/selectOptionsValue.js +10 -0
- data/lib/watir/{atoms → js_snippets}/selectText.js +3 -0
- data/lib/watir/js_snippets/selectedOptions.js +11 -0
- data/lib/watir/js_snippets/setValue.js +3 -0
- data/lib/watir/locators/element/locator.rb +24 -10
- data/lib/watir/radio_set.rb +231 -0
- data/lib/watir/user_editable.rb +16 -2
- data/lib/watirspec/remote_server.rb +2 -1
- data/spec/browser_spec.rb +8 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/watirspec/elements/div_spec.rb +22 -0
- data/spec/watirspec/elements/divs_spec.rb +1 -1
- data/spec/watirspec/elements/element_spec.rb +24 -7
- data/spec/watirspec/elements/labels_spec.rb +1 -1
- data/spec/watirspec/elements/radio_spec.rb +17 -3
- data/spec/watirspec/elements/radios_spec.rb +1 -1
- data/spec/watirspec/elements/select_list_spec.rb +167 -65
- data/spec/watirspec/elements/text_field_spec.rb +36 -0
- data/spec/watirspec/html/forms_with_input_elements.html +4 -2
- data/spec/watirspec/html/non_control_elements.html +1 -1
- data/spec/watirspec/radio_set_spec.rb +340 -0
- data/spec/watirspec_helper.rb +14 -1
- data/support/doctest_helper.rb +11 -8
- data/watir.gemspec +2 -2
- metadata +30 -11
- data/lib/watir/atoms.rb +0 -22
- data/lib/watir/atoms/README +0 -3
- data/lib/watir/extensions/select_text.rb +0 -11
data/lib/watir/user_editable.rb
CHANGED
@@ -4,7 +4,7 @@ module Watir
|
|
4
4
|
#
|
5
5
|
# Clear the element, the type in the given value.
|
6
6
|
#
|
7
|
-
# @param [String, Symbol]
|
7
|
+
# @param [String, Symbol] args
|
8
8
|
#
|
9
9
|
|
10
10
|
def set(*args)
|
@@ -15,10 +15,24 @@ module Watir
|
|
15
15
|
end
|
16
16
|
alias_method :value=, :set
|
17
17
|
|
18
|
+
#
|
19
|
+
# Uses JavaScript to enter most of the given value.
|
20
|
+
# Selenium is used to enter the first and last characters
|
21
|
+
#
|
22
|
+
# @param [String] input_value
|
23
|
+
#
|
24
|
+
|
25
|
+
def set!(input_value)
|
26
|
+
set input_value[0]
|
27
|
+
element_call { execute_js(:setValue, @element, input_value[0..-2]) }
|
28
|
+
append(input_value[-1])
|
29
|
+
raise Watir::Exception::Error, "#set! value does not match expected input" unless value == input_value
|
30
|
+
end
|
31
|
+
|
18
32
|
#
|
19
33
|
# Appends the given value to the text in the text field.
|
20
34
|
#
|
21
|
-
# @param [String, Symbol]
|
35
|
+
# @param [String, Symbol] args
|
22
36
|
#
|
23
37
|
|
24
38
|
def append(*args)
|
@@ -2,7 +2,7 @@ module WatirSpec
|
|
2
2
|
class RemoteServer
|
3
3
|
attr_reader :server
|
4
4
|
|
5
|
-
def start(port = 4444)
|
5
|
+
def start(port = 4444, args: [])
|
6
6
|
require 'selenium/server'
|
7
7
|
|
8
8
|
@server ||= Selenium::Server.new(jar,
|
@@ -10,6 +10,7 @@ module WatirSpec
|
|
10
10
|
log: !!$DEBUG,
|
11
11
|
background: true,
|
12
12
|
timeout: 60)
|
13
|
+
args.each { |arg| @server << arg }
|
13
14
|
@server.start
|
14
15
|
at_exit { @server.stop }
|
15
16
|
end
|
data/spec/browser_spec.rb
CHANGED
@@ -11,7 +11,9 @@ describe Watir::Browser do
|
|
11
11
|
@original = WatirSpec.implementation.clone
|
12
12
|
|
13
13
|
require 'watirspec/remote_server'
|
14
|
-
|
14
|
+
args = ["-Dwebdriver.chrome.driver=#{Webdrivers::Chromedriver.send :binary}",
|
15
|
+
"-Dwebdriver.gecko.driver=#{Webdrivers::Geckodriver.send :binary}"]
|
16
|
+
WatirSpec::RemoteServer.new.start(4544, args: args)
|
15
17
|
browser.close
|
16
18
|
end
|
17
19
|
|
@@ -138,10 +140,14 @@ describe Watir::Browser do
|
|
138
140
|
browser.close
|
139
141
|
@opts = WatirSpec.implementation.browser_args.last
|
140
142
|
|
141
|
-
@opts.merge!(port: '2314',
|
143
|
+
@opts.merge!(port: '2314',
|
144
|
+
driver_opts: {args: ['foo']},
|
145
|
+
listener: LocalConfig::SelectorListener.new)
|
142
146
|
|
143
147
|
@new_browser = WatirSpec.new_browser
|
144
148
|
|
149
|
+
bridge = @new_browser.wd.instance_variable_get('@bridge')
|
150
|
+
expect(bridge).to be_a Selenium::WebDriver::Support::EventFiringBridge
|
145
151
|
service = @new_browser.wd.instance_variable_get("@service")
|
146
152
|
expect(service.instance_variable_get("@extra_args")).to eq ["foo"]
|
147
153
|
expect(service.instance_variable_get("@port")).to eq 2314
|
data/spec/spec_helper.rb
CHANGED
@@ -153,6 +153,21 @@ describe "Div" do
|
|
153
153
|
expect { browser.div(xpath: "//div[@id='no_such_id']").click }.to raise_unknown_object_exception
|
154
154
|
end
|
155
155
|
end
|
156
|
+
|
157
|
+
describe "#click!" do
|
158
|
+
it "fires events when clicked" do
|
159
|
+
expect(browser.div(id: 'best_language').text).to_not 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
|
156
171
|
end
|
157
172
|
|
158
173
|
not_compliant_on :safari do
|
@@ -163,6 +178,13 @@ describe "Div" do
|
|
163
178
|
expect(messages).to include('double clicked')
|
164
179
|
end
|
165
180
|
end
|
181
|
+
|
182
|
+
describe "#double_click!" do
|
183
|
+
it "fires the ondblclick event" do
|
184
|
+
browser.div(id: 'html_test').double_click!
|
185
|
+
expect(messages).to include('double clicked')
|
186
|
+
end
|
187
|
+
end
|
166
188
|
end
|
167
189
|
|
168
190
|
not_compliant_on :firefox do
|
@@ -99,7 +99,7 @@ describe "Element" do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
it "finds finds several elements by arbitrary attribute" do
|
102
|
-
expect(browser.elements(id: /^new_user/).length).to eq
|
102
|
+
expect(browser.elements(id: /^new_user/).length).to eq 33
|
103
103
|
end
|
104
104
|
|
105
105
|
it "finds an element from an element's subtree" do
|
@@ -366,19 +366,36 @@ describe "Element" do
|
|
366
366
|
end
|
367
367
|
end
|
368
368
|
|
369
|
+
describe '#text_content' do
|
370
|
+
it 'returns inner Text code of element' do
|
371
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
372
|
+
expect(browser.div(id: 'shown').text_content).to eq('Not shownNot hidden')
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
describe '#inner_text' do
|
377
|
+
it 'returns inner HTML code of element' do
|
378
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
379
|
+
div = browser.div(id: 'shown')
|
380
|
+
expect(div.inner_text).to eq('Not hidden')
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
369
384
|
describe '#inner_html' do
|
370
385
|
it 'returns inner HTML code of element' do
|
371
|
-
browser.goto WatirSpec.url_for('
|
372
|
-
div = browser.div(id: '
|
373
|
-
|
386
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
387
|
+
div = browser.div(id: 'shown')
|
388
|
+
expected_text = "<div id=\"hidden\" style=\"display: none;\">Not shown</div><div>Not hidden</div>"
|
389
|
+
expect(div.inner_html).to eq expected_text
|
374
390
|
end
|
375
391
|
end
|
376
392
|
|
377
393
|
describe '#outer_html' do
|
378
394
|
it 'returns outer (inner + element itself) HTML code of element' do
|
379
|
-
browser.goto WatirSpec.url_for('
|
380
|
-
div = browser.div(id: '
|
381
|
-
|
395
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
396
|
+
div = browser.div(id: 'shown')
|
397
|
+
expected_text = "<div id=\"shown\"><div id=\"hidden\" style=\"display: none;\">Not shown</div><div>Not hidden</div></div>"
|
398
|
+
expect(div.outer_html).to eq expected_text
|
382
399
|
end
|
383
400
|
end
|
384
401
|
|
@@ -15,9 +15,8 @@ describe "Radio" do
|
|
15
15
|
expect(browser.radio(name: /new_user_newsletter/)).to exist
|
16
16
|
expect(browser.radio(value: "yes")).to exist
|
17
17
|
expect(browser.radio(value: /yes/)).to exist
|
18
|
-
|
19
|
-
|
20
|
-
# browser.radio(text: /yes/).to exist
|
18
|
+
expect(browser.radio(text: "Yes")).to exist
|
19
|
+
expect(browser.radio(text: /Yes/)).to exist
|
21
20
|
expect(browser.radio(class: "huge")).to exist
|
22
21
|
expect(browser.radio(class: /huge/)).to exist
|
23
22
|
expect(browser.radio(index: 0)).to exist
|
@@ -116,6 +115,21 @@ describe "Radio" do
|
|
116
115
|
end
|
117
116
|
end
|
118
117
|
|
118
|
+
describe "#text" do
|
119
|
+
it "returns the text if the radio exists" do
|
120
|
+
expect(browser.radio(id: 'new_user_newsletter_yes').text).to eq "Yes"
|
121
|
+
end
|
122
|
+
|
123
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
124
|
+
expect { browser.radio(index: 1337).text }.to raise_unknown_object_exception
|
125
|
+
end
|
126
|
+
|
127
|
+
it "returns empty string when there is no label" do
|
128
|
+
form = browser.form(id: "new_user")
|
129
|
+
expect(form.radio(index: 2).text).to eq ''
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
119
133
|
describe "#title" do
|
120
134
|
it "returns the title attribute if the radio exists" do
|
121
135
|
expect(browser.radio(id: "new_user_newsletter_no").title).to eq "Traitor!"
|
@@ -102,7 +102,7 @@ describe "SelectList" do
|
|
102
102
|
expect { browser.select_list(index: 1337).value }.to raise_unknown_object_exception
|
103
103
|
end
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
describe "#text" do
|
107
107
|
not_compliant_on :safari do
|
108
108
|
it "returns the text of the selected option" do
|
@@ -112,7 +112,7 @@ describe "SelectList" do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
it "raises UnknownObjectException if the select list doesn't exist" do
|
115
|
-
expect {browser.select_list(index: 1337).text}.to raise_unknown_object_exception
|
115
|
+
expect { browser.select_list(index: 1337).text }.to raise_unknown_object_exception
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
@@ -178,7 +178,7 @@ describe "SelectList" do
|
|
178
178
|
|
179
179
|
it "gets the currently selected item(s)" do
|
180
180
|
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Norway"]
|
181
|
-
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["
|
181
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["EN", "NO"]
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
@@ -255,52 +255,58 @@ describe "SelectList" do
|
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
258
|
+
describe "#select" do
|
259
|
+
context "when finding by value" do
|
260
|
+
it "selects an option with a String" do
|
261
|
+
browser.select_list(name: "new_user_languages").clear
|
262
|
+
browser.select_list(name: "new_user_languages").select("2")
|
263
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[EN]
|
264
|
+
end
|
265
265
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
266
|
+
it "selects an option with a Regexp" do
|
267
|
+
browser.select_list(name: "new_user_languages").clear
|
268
|
+
browser.select_list(name: "new_user_languages").select(/1|3/)
|
269
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[Danish NO]
|
270
|
+
end
|
271
|
+
end
|
270
272
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
273
|
+
context "when finding by text" do
|
274
|
+
it "selects an option with a String" do
|
275
|
+
browser.select_list(name: "new_user_country").select("Denmark")
|
276
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
277
|
+
end
|
275
278
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
279
|
+
it "selects an option with a Regexp" do
|
280
|
+
browser.select_list(name: "new_user_country").select(/Denmark/)
|
281
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
282
|
+
end
|
283
|
+
end
|
280
284
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
285
|
+
context "when finding by label" do
|
286
|
+
it "selects an option with a String" do
|
287
|
+
browser.select_list(name: "new_user_languages").clear
|
288
|
+
browser.select_list(name: "new_user_languages").select("NO")
|
289
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["NO"]
|
290
|
+
end
|
287
291
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
292
|
+
it "selects an option with a Regexp" do
|
293
|
+
browser.select_list(name: "new_user_languages").clear
|
294
|
+
browser.select_list(name: "new_user_languages").select(/^N/)
|
295
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["NO"]
|
296
|
+
end
|
297
|
+
end
|
293
298
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
+
it "selects multiple options successiveley" do
|
300
|
+
browser.select_list(name: "new_user_languages").clear
|
301
|
+
browser.select_list(name: "new_user_languages").select("Danish")
|
302
|
+
browser.select_list(name: "new_user_languages").select("Swedish")
|
303
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["Danish", "Swedish"]
|
304
|
+
end
|
299
305
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
306
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
307
|
+
it "selects empty options" do
|
308
|
+
browser.select_list(id: "delete_user_username").select("")
|
309
|
+
expect(browser.select_list(id: "delete_user_username").selected_options.map(&:text)).to eq [""]
|
304
310
|
end
|
305
311
|
end
|
306
312
|
|
@@ -308,10 +314,6 @@ describe "SelectList" do
|
|
308
314
|
expect(browser.select_list(name: "new_user_languages").select("Danish")).to eq "Danish"
|
309
315
|
end
|
310
316
|
|
311
|
-
it "returns the first matching value if there are multiple matches" do
|
312
|
-
expect(browser.select_list(name: "new_user_languages").select_all(/ish/)).to eq "Danish"
|
313
|
-
end
|
314
|
-
|
315
317
|
not_compliant_on :safari do
|
316
318
|
it "fires onchange event when selecting an item" do
|
317
319
|
browser.select_list(id: "new_user_languages").select("Danish")
|
@@ -326,13 +328,7 @@ describe "SelectList" do
|
|
326
328
|
browser.select_list(id: "new_user_languages").select("English")
|
327
329
|
expect(messages.size).to eq 3
|
328
330
|
end
|
329
|
-
end
|
330
331
|
|
331
|
-
it "returns the text of the selected option" do
|
332
|
-
expect(browser.select_list(id: "new_user_languages").select("English")).to eq "English"
|
333
|
-
end
|
334
|
-
|
335
|
-
not_compliant_on :safari do
|
336
332
|
it "returns an empty string when selecting an option that disappears when selected" do
|
337
333
|
expect(browser.select_list(id: 'obsolete').select('sweden')).to eq ''
|
338
334
|
end
|
@@ -350,7 +346,7 @@ describe "SelectList" do
|
|
350
346
|
Watir.default_timeout = 2
|
351
347
|
begin
|
352
348
|
start_time = ::Time.now
|
353
|
-
expect {select_list.select('No')}.to raise_error Watir::Exception::NoValueFoundException
|
349
|
+
expect { select_list.select('No') }.to raise_error Watir::Exception::NoValueFoundException
|
354
350
|
expect(::Time.now - start_time).to be > 2
|
355
351
|
ensure
|
356
352
|
Watir.default_timeout = 30
|
@@ -372,26 +368,132 @@ describe "SelectList" do
|
|
372
368
|
end
|
373
369
|
end
|
374
370
|
|
375
|
-
#
|
376
|
-
|
377
|
-
|
378
|
-
|
371
|
+
describe "#select!" do
|
372
|
+
context "when finding by value" do
|
373
|
+
it "selects an option with a String" do
|
374
|
+
browser.select_list(name: "new_user_languages").clear
|
375
|
+
browser.select_list(name: "new_user_languages").select!("2")
|
376
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[EN]
|
377
|
+
end
|
378
|
+
|
379
|
+
it "selects an option with a Regex" do
|
380
|
+
browser.select_list(name: "new_user_languages").clear
|
381
|
+
browser.select_list(name: "new_user_languages").select!(/2/)
|
382
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[EN]
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
context "when finding by text" do
|
387
|
+
it "selects an option with a String" do
|
388
|
+
browser.select_list(name: "new_user_country").select!("Denmark")
|
389
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
390
|
+
end
|
391
|
+
|
392
|
+
it "selects an option with a Regexp" do
|
393
|
+
browser.select_list(name: "new_user_country").select!(/Denmark/)
|
394
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
context "when finding by label" do
|
399
|
+
it "selects an option with a String" do
|
379
400
|
browser.select_list(name: "new_user_languages").clear
|
380
|
-
browser.select_list(name: "new_user_languages").
|
381
|
-
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq
|
401
|
+
browser.select_list(name: "new_user_languages").select!("NO")
|
402
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["NO"]
|
382
403
|
end
|
383
404
|
|
384
|
-
it "selects
|
405
|
+
it "selects an option with a Regexp" do
|
385
406
|
browser.select_list(name: "new_user_languages").clear
|
386
|
-
browser.select_list(name: "new_user_languages").
|
387
|
-
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq
|
407
|
+
browser.select_list(name: "new_user_languages").select!(/NO/)
|
408
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["NO"]
|
388
409
|
end
|
410
|
+
end
|
389
411
|
|
390
|
-
|
391
|
-
|
392
|
-
|
412
|
+
it "selects multiple items successively" do
|
413
|
+
browser.select_list(name: "new_user_languages").clear
|
414
|
+
browser.select_list(name: "new_user_languages").select!("Danish")
|
415
|
+
browser.select_list(name: "new_user_languages").select!("Swedish")
|
416
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["Danish", "Swedish"]
|
417
|
+
end
|
418
|
+
|
419
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255957", :firefox do
|
420
|
+
it "selects empty options" do
|
421
|
+
browser.select_list(id: "delete_user_username").select!("")
|
422
|
+
expect(browser.select_list(id: "delete_user_username").selected_options.map(&:text)).to eq [""]
|
393
423
|
end
|
394
424
|
end
|
425
|
+
|
426
|
+
it "returns the value selected" do
|
427
|
+
browser.select_list(name: "new_user_languages").clear
|
428
|
+
expect(browser.select_list(name: "new_user_languages").select!("Danish")).to eq "Danish"
|
429
|
+
end
|
430
|
+
|
431
|
+
it "selects options with a single-quoted value" do
|
432
|
+
browser.select_list(id: 'single-quote').select!("'foo'")
|
433
|
+
end
|
434
|
+
|
435
|
+
it "raises NoValueFoundException if the option doesn't exist" do
|
436
|
+
expect { browser.select_list(id: "new_user_country").select!("missing_option") }.to raise_no_value_found_exception
|
437
|
+
expect { browser.select_list(id: "new_user_country").select!(/missing_option/) }.to raise_no_value_found_exception
|
438
|
+
end
|
439
|
+
|
440
|
+
it "raises ObjectDisabledException if the option is disabled" do
|
441
|
+
browser.select_list(id: "new_user_languages").clear
|
442
|
+
expect { browser.select_list(id: "new_user_languages").select!("Russian") }.to raise_object_disabled_exception
|
443
|
+
end
|
444
|
+
|
445
|
+
it "raises a TypeError if argument is not a String, Regexp or Numeric" do
|
446
|
+
browser.select_list(id: "new_user_languages").clear
|
447
|
+
expect { browser.select_list(id: "new_user_languages").select!([]) }.to raise_error(TypeError)
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
describe "#select_all" do
|
452
|
+
it "selects multiple options based on text" do
|
453
|
+
browser.select_list(name: "new_user_languages").clear
|
454
|
+
browser.select_list(name: "new_user_languages").select_all(/ish/)
|
455
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["Danish", "EN", "Swedish"]
|
456
|
+
end
|
457
|
+
|
458
|
+
it "selects multiple options based on labels" do
|
459
|
+
browser.select_list(name: "new_user_languages").clear
|
460
|
+
browser.select_list(name: "new_user_languages").select_all(/NO|EN/)
|
461
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["EN", "NO"]
|
462
|
+
end
|
463
|
+
|
464
|
+
it "returns the first matching value if there are multiple matches" do
|
465
|
+
expect(browser.select_list(name: "new_user_languages").select_all(/ish/)).to eq "Danish"
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
describe "#select_all!" do
|
470
|
+
it "selects multiple options based on value" do
|
471
|
+
browser.select_list(name: "new_user_languages").clear
|
472
|
+
browser.select_list(name: "new_user_languages").select_all!(/\d+/)
|
473
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["Danish", "EN", "NO", "Russian"]
|
474
|
+
end
|
475
|
+
|
476
|
+
it "selects multiple options based on text" do
|
477
|
+
browser.select_list(name: "new_user_languages").clear
|
478
|
+
browser.select_list(name: "new_user_languages").select_all!(/ish/)
|
479
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["Danish", "EN", "Swedish"]
|
480
|
+
end
|
481
|
+
|
482
|
+
it "selects multiple options based on labels" do
|
483
|
+
browser.select_list(name: "new_user_languages").clear
|
484
|
+
browser.select_list(name: "new_user_languages").select_all!(/NO|EN/)
|
485
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["EN", "NO"]
|
486
|
+
end
|
487
|
+
|
488
|
+
it "returns the first matching value if there are multiple matches" do
|
489
|
+
expect(browser.select_list(name: "new_user_languages").select_all!(/ish/)).to eq "Danish"
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
493
|
+
# deprecate?
|
494
|
+
not_compliant_on :safari do
|
495
|
+
describe "#select_value" do
|
496
|
+
end
|
395
497
|
end
|
396
498
|
|
397
499
|
end
|