watir 6.16.5 → 6.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +32 -107
- data/.travis.yml +24 -21
- data/CHANGES.md +16 -0
- data/Gemfile +3 -1
- data/Rakefile +3 -3
- data/appveyor.yml +2 -1
- data/lib/watir-webdriver.rb +1 -1
- data/lib/watir.rb +0 -1
- data/lib/watir/adjacent.rb +8 -10
- data/lib/watir/after_hooks.rb +4 -4
- data/lib/watir/browser.rb +5 -1
- data/lib/watir/capabilities.rb +9 -6
- data/lib/watir/cookies.rb +1 -1
- data/lib/watir/elements/element.rb +59 -46
- data/lib/watir/elements/file_field.rb +1 -0
- data/lib/watir/elements/iframe.rb +2 -2
- data/lib/watir/elements/link.rb +0 -9
- data/lib/watir/elements/radio.rb +1 -1
- data/lib/watir/elements/select.rb +2 -2
- data/lib/watir/generator/base/spec_extractor.rb +4 -4
- data/lib/watir/js_execution.rb +1 -1
- data/lib/watir/legacy_wait.rb +1 -1
- data/lib/watir/locators/element/selector_builder.rb +11 -12
- data/lib/watir/locators/element/selector_builder/xpath.rb +40 -13
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +3 -1
- data/lib/watir/logger.rb +5 -2
- data/lib/watir/version.rb +1 -1
- data/lib/watir/window.rb +1 -1
- data/lib/watirspec.rb +1 -1
- data/lib/watirspec/guards.rb +1 -1
- data/lib/watirspec/rake_tasks.rb +2 -0
- data/lib/watirspec/runner.rb +4 -0
- data/spec/unit/container_spec.rb +1 -1
- data/spec/unit/logger_spec.rb +5 -7
- data/spec/unit/selector_builder/button_spec.rb +16 -15
- data/spec/unit/selector_builder/element_spec.rb +58 -9
- data/spec/unit/selector_builder/text_field_spec.rb +14 -14
- data/spec/watirspec/after_hooks_spec.rb +64 -78
- data/spec/watirspec/alert_spec.rb +69 -79
- data/spec/watirspec/browser_spec.rb +48 -46
- data/spec/watirspec/cookies_spec.rb +52 -37
- data/spec/watirspec/drag_and_drop_spec.rb +14 -38
- data/spec/watirspec/elements/button_spec.rb +2 -0
- data/spec/watirspec/elements/buttons_spec.rb +1 -1
- data/spec/watirspec/elements/checkbox_spec.rb +8 -4
- data/spec/watirspec/elements/date_field_spec.rb +18 -9
- data/spec/watirspec/elements/date_time_field_spec.rb +3 -4
- data/spec/watirspec/elements/div_spec.rb +62 -54
- data/spec/watirspec/elements/element_spec.rb +60 -78
- data/spec/watirspec/elements/elements_spec.rb +12 -3
- data/spec/watirspec/elements/filefield_spec.rb +25 -50
- data/spec/watirspec/elements/form_spec.rb +6 -8
- data/spec/watirspec/elements/frame_spec.rb +10 -13
- data/spec/watirspec/elements/iframe_spec.rb +17 -12
- data/spec/watirspec/elements/iframes_spec.rb +2 -2
- data/spec/watirspec/elements/link_spec.rb +18 -9
- data/spec/watirspec/elements/links_spec.rb +11 -3
- data/spec/watirspec/elements/option_spec.rb +15 -17
- data/spec/watirspec/elements/select_list_spec.rb +66 -80
- data/spec/watirspec/elements/text_field_spec.rb +8 -4
- data/spec/watirspec/elements/tr_spec.rb +0 -9
- data/spec/watirspec/html/forms_with_input_elements.html +1 -0
- data/spec/watirspec/html/iframes.html +3 -0
- data/spec/watirspec/html/non_control_elements.html +4 -4
- data/spec/watirspec/html/right_click.html +12 -0
- data/spec/watirspec/html/wait.html +1 -1
- data/spec/watirspec/relaxed_locate_spec.rb +16 -20
- data/spec/watirspec/support/rspec_matchers.rb +7 -6
- data/spec/watirspec/user_editable_spec.rb +1 -1
- data/spec/watirspec/wait_spec.rb +13 -17
- data/spec/watirspec/window_switching_spec.rb +162 -163
- data/spec/watirspec_helper.rb +7 -5
- data/watir.gemspec +4 -5
- metadata +14 -16
- data/lib/watir/elements/area.rb +0 -10
@@ -37,12 +37,21 @@ describe 'Elements' do
|
|
37
37
|
it 'finds elements by visible text' do
|
38
38
|
browser.goto WatirSpec.url_for('non_control_elements.html')
|
39
39
|
container = browser.div(id: 'visible_text')
|
40
|
+
|
40
41
|
expect(container.elements(visible_text: 'all visible').count).to eq(1)
|
41
42
|
expect(container.elements(visible_text: /all visible/).count).to eq(1)
|
42
|
-
expect(container.elements(visible_text: 'some visible').count).to eq(1)
|
43
43
|
expect(container.elements(visible_text: /some visible/).count).to eq(1)
|
44
|
-
|
45
|
-
|
44
|
+
end
|
45
|
+
|
46
|
+
bug 'Safari is not filtering out hidden text', :safari do
|
47
|
+
it 'finds elements in spite of hidden text' do
|
48
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
49
|
+
container = browser.div(id: 'visible_text')
|
50
|
+
|
51
|
+
expect(container.elements(visible_text: 'some visible').count).to eq(1)
|
52
|
+
expect(container.elements(visible_text: 'none visible').count).to eq(0)
|
53
|
+
expect(container.elements(visible_text: /none visible/).count).to eq(0)
|
54
|
+
end
|
46
55
|
end
|
47
56
|
end
|
48
57
|
end
|
@@ -92,66 +92,41 @@ describe 'FileField' do
|
|
92
92
|
# Manipulation methods
|
93
93
|
|
94
94
|
describe '#set' do
|
95
|
-
|
96
|
-
|
97
|
-
it 'is able to set a file path in the field and click the upload button and fire the onchange event' do
|
98
|
-
browser.goto WatirSpec.url_for('forms_with_input_elements.html')
|
95
|
+
it 'is able to set a file path in the field and click the upload button and fire the onchange event' do
|
96
|
+
browser.goto WatirSpec.url_for('forms_with_input_elements.html')
|
99
97
|
|
100
|
-
|
101
|
-
|
98
|
+
element = browser.file_field(name: 'new_user_portrait')
|
99
|
+
element.upload __FILE__
|
102
100
|
|
103
|
-
|
101
|
+
expect(element.value).to include(File.basename(__FILE__)) # only some browser will return the full path
|
102
|
+
expect(messages.first).to include(File.basename(__FILE__))
|
104
103
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
browser.button(name: 'new_user_submit').click
|
109
|
-
end
|
110
|
-
end
|
104
|
+
browser.button(name: 'new_user_submit').click
|
105
|
+
end
|
111
106
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
107
|
+
it 'raises an error if the file does not exist' do
|
108
|
+
expect {
|
109
|
+
browser.file_field.set(File.join(Dir.tmpdir, 'unlikely-to-exist'))
|
110
|
+
}.to raise_error(Errno::ENOENT)
|
117
111
|
end
|
118
112
|
end
|
119
113
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
it 'is able to set a file path in the field and click the upload button and fire the onchange event' do
|
124
|
-
browser.goto WatirSpec.url_for('forms_with_input_elements.html')
|
125
|
-
|
126
|
-
path = File.expand_path(__FILE__)
|
127
|
-
element = browser.file_field(name: 'new_user_portrait')
|
114
|
+
describe '#value=' do
|
115
|
+
it 'is able to set a file path in the field and click the upload button and fire the onchange event' do
|
116
|
+
browser.goto WatirSpec.url_for('forms_with_input_elements.html')
|
128
117
|
|
129
|
-
|
130
|
-
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
not_compliant_on :internet_explorer, :firefox, :chrome do
|
135
|
-
it 'does not raise an error if the file does not exist' do
|
136
|
-
path = File.join(Dir.tmpdir, 'unlikely-to-exist')
|
137
|
-
browser.file_field.value = path
|
138
|
-
|
139
|
-
expected = path
|
140
|
-
expected.tr!('/', '\\') if Selenium::WebDriver::Platform.windows?
|
118
|
+
path = File.expand_path(__FILE__)
|
119
|
+
element = browser.file_field(name: 'new_user_portrait')
|
141
120
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
end
|
121
|
+
element.value = path
|
122
|
+
expect(element.value).to include(File.basename(path)) # only some browser will return the full path
|
123
|
+
end
|
146
124
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
expect(value).to match(/\.travis\.yml$/)
|
153
|
-
end
|
154
|
-
end
|
125
|
+
not_compliant_on :internet_explorer, %i[chrome windows] do
|
126
|
+
it 'does not alter its argument' do
|
127
|
+
value = File.expand_path '.travis.yml'
|
128
|
+
browser.file_field.value = value
|
129
|
+
expect(value).to match(/\.travis\.yml$/)
|
155
130
|
end
|
156
131
|
end
|
157
132
|
end
|
@@ -51,14 +51,12 @@ describe 'Form' do
|
|
51
51
|
expect(browser.text).to include('Semantic table')
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
expect(messages[0]).to eq 'submit'
|
61
|
-
end
|
54
|
+
it 'triggers onsubmit event and takes its result into account' do
|
55
|
+
form = browser.form(name: 'user_new')
|
56
|
+
form.submit
|
57
|
+
expect(form).to exist
|
58
|
+
expect(messages.size).to eq 1
|
59
|
+
expect(messages[0]).to eq 'submit'
|
62
60
|
end
|
63
61
|
|
64
62
|
compliant_on :relaxed_locate do
|
@@ -9,13 +9,11 @@ describe 'Frame' do
|
|
9
9
|
browser.goto(WatirSpec.url_for('frames.html'))
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
expect(browser.frame(id: 'frame_2').text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
18
|
-
end
|
12
|
+
it 'handles crossframe javascript' do
|
13
|
+
expect(browser.frame(id: 'frame_1').text_field(name: 'senderElement').value).to eq 'send_this_value'
|
14
|
+
expect(browser.frame(id: 'frame_2').text_field(name: 'recieverElement').value).to eq 'old_value'
|
15
|
+
browser.frame(id: 'frame_1').button(id: 'send').click
|
16
|
+
expect(browser.frame(id: 'frame_2').text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
19
17
|
end
|
20
18
|
|
21
19
|
describe '#exist?' do
|
@@ -50,14 +48,13 @@ describe 'Frame' do
|
|
50
48
|
end
|
51
49
|
|
52
50
|
bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1255946', :firefox do
|
53
|
-
|
54
|
-
|
55
|
-
browser.goto(WatirSpec.url_for('nested_frames.html'))
|
51
|
+
it 'handles nested frames' do
|
52
|
+
browser.goto(WatirSpec.url_for('nested_frames.html'))
|
56
53
|
|
57
|
-
|
54
|
+
browser.frame(id: 'two').frame(id: 'three').link(id: 'four').click
|
58
55
|
|
59
|
-
|
60
|
-
|
56
|
+
Watir::Wait.until { browser.title == 'definition_lists' }
|
57
|
+
expect { browser.goto(WatirSpec.url_for('nested_frames.html')) }.to_not raise_exception
|
61
58
|
end
|
62
59
|
end
|
63
60
|
|
@@ -78,12 +78,17 @@ describe 'IFrame' do
|
|
78
78
|
expect(browser.iframe(xpath: "//iframe[@id='no_such_id']")).to_not exist
|
79
79
|
end
|
80
80
|
|
81
|
-
it 'returns
|
81
|
+
it 'returns true if an element in an iframe does exist' do
|
82
82
|
expect(browser.iframe.element(css: '#senderElement')).to exist
|
83
83
|
expect(browser.iframe.element(id: 'senderElement')).to exist
|
84
84
|
end
|
85
85
|
|
86
|
-
it 'returns true
|
86
|
+
it 'returns true for multiple elements that exist in an iframe with a parent selector' do
|
87
|
+
expect(browser.div(class: 'wrapper').iframe.element(id: 'first_grandson')).to exist
|
88
|
+
expect(browser.div(class: 'wrapper').iframe.element(id: 'second_grandson')).to exist
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'returns false if an element in an iframe does not exist' do
|
87
92
|
expect(browser.iframe.element(css: '#no_such_id')).to_not exist
|
88
93
|
expect(browser.iframe.element(id: 'no_such_id')).to_not exist
|
89
94
|
end
|
@@ -112,13 +117,11 @@ describe 'IFrame' do
|
|
112
117
|
end
|
113
118
|
|
114
119
|
bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1255946', :firefox do
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
browser.iframe(id: 'two').iframe(id: 'three').link(id: 'four').click
|
120
|
+
it 'handles nested iframes' do
|
121
|
+
browser.goto(WatirSpec.url_for('nested_iframes.html'))
|
122
|
+
browser.iframe(id: 'two').iframe(id: 'three').link(id: 'four').click
|
119
123
|
|
120
|
-
|
121
|
-
end
|
124
|
+
Watir::Wait.until { browser.title == 'definition_lists' }
|
122
125
|
end
|
123
126
|
end
|
124
127
|
|
@@ -141,10 +144,12 @@ describe 'IFrame' do
|
|
141
144
|
end
|
142
145
|
end
|
143
146
|
|
144
|
-
|
145
|
-
|
146
|
-
element
|
147
|
-
|
147
|
+
bug 'Safari returns NoSuchElementError instead of Stale Error', :safari do
|
148
|
+
it 'switches between iframe and parent when needed' do
|
149
|
+
browser.iframe(id: 'iframe_1').elements.each do |element|
|
150
|
+
element.text
|
151
|
+
browser.h1.text
|
152
|
+
end
|
148
153
|
end
|
149
154
|
end
|
150
155
|
|
@@ -13,13 +13,13 @@ describe 'IFrames' do
|
|
13
13
|
|
14
14
|
describe 'eql?' do
|
15
15
|
it 'matches equality of iframe with that from a collection' do
|
16
|
-
expect(browser.iframes.last).to eq browser.iframe(id: '
|
16
|
+
expect(browser.iframes.last).to eq browser.iframe(id: 'iframe_3')
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '#length' do
|
21
21
|
it 'returns the correct number of iframes' do
|
22
|
-
expect(browser.iframes.length).to eq
|
22
|
+
expect(browser.iframes.length).to eq 3
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -143,11 +143,13 @@ describe 'Link' do
|
|
143
143
|
expect { browser.link(index: 1337).click }.to raise_unknown_object_exception
|
144
144
|
end
|
145
145
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
146
|
+
bug 'Safari throws a not interactable error', :safari do
|
147
|
+
it 'clicks a link with no text content but an img child' do
|
148
|
+
browser.goto WatirSpec.url_for('images.html')
|
149
|
+
browser.link(href: /definition_lists.html/).click
|
150
|
+
Watir::Wait.while { browser.title == 'Images' || browser.title == '' }
|
151
|
+
expect(browser.title).to eq 'definition_lists'
|
152
|
+
end
|
151
153
|
end
|
152
154
|
end
|
153
155
|
|
@@ -157,18 +159,25 @@ describe 'Link' do
|
|
157
159
|
|
158
160
|
expect(browser.link(visible_text: 'all visible')).to exist
|
159
161
|
expect(browser.link(visible_text: /all visible/)).to exist
|
160
|
-
expect(browser.link(visible_text: 'some visible')).to exist
|
161
162
|
expect(browser.link(visible_text: /some visible/)).to exist
|
162
|
-
expect(browser.link(visible_text: 'none visible')).not_to exist
|
163
|
-
expect(browser.link(visible_text: /none visible/)).not_to exist
|
164
163
|
|
165
164
|
expect(browser.link(visible_text: 'Link 2', class: 'external')).to exist
|
166
165
|
expect(browser.link(visible_text: /Link 2/, class: 'external')).to exist
|
167
166
|
end
|
168
167
|
|
168
|
+
bug 'Safari is not filtering out hidden text', :safari do
|
169
|
+
it 'finds links in spite of hidden text' do
|
170
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
171
|
+
|
172
|
+
expect(browser.link(visible_text: 'some visible')).to exist
|
173
|
+
expect(browser.link(visible_text: 'none visible')).not_to exist
|
174
|
+
expect(browser.link(visible_text: /none visible/)).not_to exist
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
169
178
|
it 'raises exception unless value is a String or a RegExp' do
|
170
179
|
browser.goto WatirSpec.url_for('non_control_elements.html')
|
171
|
-
msg = /expected one of \[String, Regexp\], got 7
|
180
|
+
msg = /expected one of \[String, Regexp\], got 7:Integer/
|
172
181
|
expect { browser.link(visible_text: 7).exists? }.to raise_exception(TypeError, msg)
|
173
182
|
end
|
174
183
|
end
|
@@ -46,10 +46,18 @@ describe 'Links' do
|
|
46
46
|
container = browser.div(id: 'visible_text')
|
47
47
|
expect(container.links(visible_text: 'all visible').count).to eq(1)
|
48
48
|
expect(container.links(visible_text: /all visible/).count).to eq(1)
|
49
|
-
expect(container.links(visible_text: 'some visible').count).to eq(1)
|
50
49
|
expect(container.links(visible_text: /some visible/).count).to eq(1)
|
51
|
-
|
52
|
-
|
50
|
+
end
|
51
|
+
|
52
|
+
bug 'Safari is not filtering out hidden text', :safari do
|
53
|
+
it 'finds links in spite of hidden text' do
|
54
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
55
|
+
container = browser.div(id: 'visible_text')
|
56
|
+
|
57
|
+
expect(container.links(visible_text: 'some visible').count).to eq(1)
|
58
|
+
expect(container.links(visible_text: 'none visible').count).to eq(0)
|
59
|
+
expect(container.links(visible_text: /none visible/).count).to eq(0)
|
60
|
+
end
|
53
61
|
end
|
54
62
|
end
|
55
63
|
end
|
@@ -66,26 +66,24 @@ describe 'Option' do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
describe '#select' do
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
69
|
+
it 'selects the chosen option (page context)' do
|
70
|
+
browser.option(text: 'Denmark').select
|
71
|
+
expect(browser.select_list(name: 'new_user_country').selected_options.map(&:text)).to eq ['Denmark']
|
72
|
+
end
|
74
73
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
it 'selects the chosen option (select_list context)' do
|
75
|
+
browser.select_list(name: 'new_user_country').option(text: 'Denmark').select
|
76
|
+
expect(browser.select_list(name: 'new_user_country').selected_options.map(&:text)).to eq ['Denmark']
|
77
|
+
end
|
79
78
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
it 'selects the option when found by text (page context)' do
|
80
|
+
browser.option(text: 'Sweden').select
|
81
|
+
expect(browser.option(text: 'Sweden')).to be_selected
|
82
|
+
end
|
84
83
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
84
|
+
it 'selects the option when found by text (select_list context)' do
|
85
|
+
browser.select_list(name: 'new_user_country').option(text: 'Sweden').select
|
86
|
+
expect(browser.select_list(name: 'new_user_country').option(text: 'Sweden')).to be_selected
|
89
87
|
end
|
90
88
|
|
91
89
|
it 'raises UnknownObjectException if the option does not exist (page context)' do
|
@@ -75,12 +75,10 @@ describe 'SelectList' do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
describe '#value' do
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
expect(browser.select_list(index: 0).value).to eq '3'
|
83
|
-
end
|
78
|
+
it 'returns the value of the selected option' do
|
79
|
+
expect(browser.select_list(index: 0).value).to eq '2'
|
80
|
+
browser.select_list(index: 0).select(/Sweden/)
|
81
|
+
expect(browser.select_list(index: 0).value).to eq '3'
|
84
82
|
end
|
85
83
|
|
86
84
|
it "raises UnknownObjectException if the select list doesn't exist" do
|
@@ -89,16 +87,14 @@ describe 'SelectList' do
|
|
89
87
|
end
|
90
88
|
|
91
89
|
describe '#text' do
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
90
|
+
it 'returns the text of the selected option' do
|
91
|
+
expect(browser.select_list(index: 0).text).to eq 'Norway'
|
92
|
+
browser.select_list(index: 0).select(/Sweden/)
|
93
|
+
expect(browser.select_list(index: 0).text).to eq 'Sweden'
|
94
|
+
end
|
98
95
|
|
99
|
-
|
100
|
-
|
101
|
-
end
|
96
|
+
it "raises UnknownObjectException if the select list doesn't exist" do
|
97
|
+
expect { browser.select_list(index: 1337).text }.to raise_unknown_object_exception
|
102
98
|
end
|
103
99
|
end
|
104
100
|
|
@@ -168,11 +164,9 @@ describe 'SelectList' do
|
|
168
164
|
end
|
169
165
|
|
170
166
|
describe '#clear' do
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
expect(browser.select_list(name: 'new_user_languages').selected_options).to be_empty
|
175
|
-
end
|
167
|
+
it 'clears the selection when possible' do
|
168
|
+
browser.select_list(name: 'new_user_languages').clear
|
169
|
+
expect(browser.select_list(name: 'new_user_languages').selected_options).to be_empty
|
176
170
|
end
|
177
171
|
|
178
172
|
it 'does not clear selections if the select list does not allow multiple selections' do
|
@@ -187,16 +181,14 @@ describe 'SelectList' do
|
|
187
181
|
expect { browser.select_list(name: 'no_such_name').clear }.to raise_unknown_object_exception
|
188
182
|
end
|
189
183
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
end
|
184
|
+
it 'fires onchange event' do
|
185
|
+
browser.select_list(name: 'new_user_languages').clear
|
186
|
+
expect(messages.size).to eq 2
|
187
|
+
end
|
195
188
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
end
|
189
|
+
it "doesn't fire onchange event for already cleared option" do
|
190
|
+
browser.select_list(name: 'new_user_languages').option.clear
|
191
|
+
expect(messages.size).to eq 0
|
200
192
|
end
|
201
193
|
end
|
202
194
|
|
@@ -214,30 +206,28 @@ describe 'SelectList' do
|
|
214
206
|
end
|
215
207
|
end
|
216
208
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
end
|
209
|
+
describe '#selected?' do
|
210
|
+
it 'returns true if the given option is selected by text' do
|
211
|
+
browser.select_list(name: 'new_user_country').select('Denmark')
|
212
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected('Denmark')
|
213
|
+
end
|
223
214
|
|
224
|
-
|
225
|
-
|
226
|
-
|
215
|
+
it 'returns false if the given option is not selected by text' do
|
216
|
+
expect(browser.select_list(name: 'new_user_country')).to_not be_selected('Sweden')
|
217
|
+
end
|
227
218
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
219
|
+
it 'returns true if the given option is selected by label' do
|
220
|
+
browser.select_list(name: 'new_user_country').select('Germany')
|
221
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected('Germany')
|
222
|
+
end
|
232
223
|
|
233
|
-
|
234
|
-
|
235
|
-
|
224
|
+
it 'returns false if the given option is not selected by label' do
|
225
|
+
expect(browser.select_list(name: 'new_user_country')).to_not be_selected('Germany')
|
226
|
+
end
|
236
227
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
end
|
228
|
+
it "raises UnknownObjectException if the option doesn't exist" do
|
229
|
+
expect { browser.select_list(name: 'new_user_country').selected?('missing_option') }
|
230
|
+
.to raise_unknown_object_exception
|
241
231
|
end
|
242
232
|
end
|
243
233
|
|
@@ -301,7 +291,7 @@ describe 'SelectList' do
|
|
301
291
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
302
292
|
end
|
303
293
|
|
304
|
-
bug '
|
294
|
+
bug 'Safari is returning click intercepted error', :safari do
|
305
295
|
it 'selects empty options' do
|
306
296
|
browser.select_list(id: 'delete_user_username').select('')
|
307
297
|
expect(browser.select_list(id: 'delete_user_username').selected_options.map(&:text)).to eq ['']
|
@@ -312,21 +302,21 @@ describe 'SelectList' do
|
|
312
302
|
expect(browser.select_list(name: 'new_user_languages').select('Danish')).to eq 'Danish'
|
313
303
|
end
|
314
304
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
end
|
305
|
+
it 'fires onchange event when selecting an item' do
|
306
|
+
browser.select_list(id: 'new_user_languages').select('Danish')
|
307
|
+
expect(messages).to eq ['changed language']
|
308
|
+
end
|
320
309
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
310
|
+
it "doesn't fire onchange event when selecting an already selected item" do
|
311
|
+
browser.select_list(id: 'new_user_languages').clear # removes the two pre-selected options
|
312
|
+
browser.select_list(id: 'new_user_languages').select('English')
|
313
|
+
expect(messages.size).to eq 3
|
325
314
|
|
326
|
-
|
327
|
-
|
328
|
-
|
315
|
+
browser.select_list(id: 'new_user_languages').select('English')
|
316
|
+
expect(messages.size).to eq 3
|
317
|
+
end
|
329
318
|
|
319
|
+
bug 'Safari is returning click intercepted error', :safari do
|
330
320
|
it 'returns an empty string when selecting an option that disappears when selected' do
|
331
321
|
expect(browser.select_list(id: 'obsolete').select('sweden')).to eq ''
|
332
322
|
end
|
@@ -353,9 +343,11 @@ describe 'SelectList' do
|
|
353
343
|
.to raise_no_value_found_exception message
|
354
344
|
end
|
355
345
|
|
356
|
-
|
357
|
-
|
358
|
-
.
|
346
|
+
bug 'Safari is returning object enabled instead of disabled', :safari do
|
347
|
+
it 'raises ObjectDisabledException if the option is disabled' do
|
348
|
+
expect { browser.select_list(name: 'new_user_languages').select('Russian') }
|
349
|
+
.to raise_object_disabled_exception
|
350
|
+
end
|
359
351
|
end
|
360
352
|
|
361
353
|
it 'raises a TypeError if argument is not a String, Regexp or Numeric' do
|
@@ -423,11 +415,9 @@ describe 'SelectList' do
|
|
423
415
|
expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
|
424
416
|
end
|
425
417
|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
expect(browser.select_list(id: 'delete_user_username').selected_options.map(&:text)).to eq ['']
|
430
|
-
end
|
418
|
+
it 'selects empty options' do
|
419
|
+
browser.select_list(id: 'delete_user_username').select!('')
|
420
|
+
expect(browser.select_list(id: 'delete_user_username').selected_options.map(&:text)).to eq ['']
|
431
421
|
end
|
432
422
|
|
433
423
|
it 'returns the value selected' do
|
@@ -454,10 +444,12 @@ describe 'SelectList' do
|
|
454
444
|
.to raise_no_value_found_exception
|
455
445
|
end
|
456
446
|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
.
|
447
|
+
bug 'Safari is returning object enabled instead of disabled', :safari do
|
448
|
+
it 'raises ObjectDisabledException if the option is disabled' do
|
449
|
+
browser.select_list(id: 'new_user_languages').clear
|
450
|
+
expect { browser.select_list(id: 'new_user_languages').select!('Russian') }
|
451
|
+
.to raise_object_disabled_exception
|
452
|
+
end
|
461
453
|
end
|
462
454
|
|
463
455
|
it 'raises a TypeError if argument is not a String, Regexp or Numeric' do
|
@@ -540,10 +532,4 @@ describe 'SelectList' do
|
|
540
532
|
expect(browser.select_list(name: 'new_user_languages').select_all!(/ish/)).to eq 'Danish'
|
541
533
|
end
|
542
534
|
end
|
543
|
-
|
544
|
-
# deprecate?
|
545
|
-
not_compliant_on :safari do
|
546
|
-
describe '#select_value' do
|
547
|
-
end
|
548
|
-
end
|
549
535
|
end
|