capybara 3.16.2 → 3.17.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/History.md +13 -0
- data/README.md +1 -1
- data/lib/capybara.rb +2 -71
- data/lib/capybara/config.rb +1 -2
- data/lib/capybara/node/actions.rb +5 -5
- data/lib/capybara/node/base.rb +4 -4
- data/lib/capybara/node/element.rb +5 -5
- data/lib/capybara/node/finders.rb +6 -4
- data/lib/capybara/node/simple.rb +3 -2
- data/lib/capybara/queries/selector_query.rb +5 -5
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/registrations/drivers.rb +36 -0
- data/lib/capybara/registrations/servers.rb +38 -0
- data/lib/capybara/result.rb +2 -2
- data/lib/capybara/rspec/matcher_proxies.rb +2 -2
- data/lib/capybara/rspec/matchers/base.rb +2 -2
- data/lib/capybara/selector.rb +55 -32
- data/lib/capybara/selector/css.rb +1 -1
- data/lib/capybara/selector/filters/base.rb +1 -1
- data/lib/capybara/selector/selector.rb +1 -0
- data/lib/capybara/selenium/driver.rb +84 -43
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +16 -4
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +23 -0
- data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +5 -0
- data/lib/capybara/selenium/driver_specializations/safari_driver.rb +14 -1
- data/lib/capybara/selenium/extensions/find.rb +48 -37
- data/lib/capybara/selenium/logger_suppressor.rb +29 -0
- data/lib/capybara/selenium/node.rb +22 -8
- data/lib/capybara/selenium/nodes/chrome_node.rb +8 -2
- data/lib/capybara/server/animation_disabler.rb +1 -1
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +3 -3
- data/lib/capybara/session/config.rb +2 -8
- data/lib/capybara/spec/session/attach_file_spec.rb +1 -1
- data/lib/capybara/spec/session/check_spec.rb +4 -4
- data/lib/capybara/spec/session/choose_spec.rb +2 -2
- data/lib/capybara/spec/session/click_button_spec.rb +28 -1
- data/lib/capybara/spec/session/fill_in_spec.rb +2 -2
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +14 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +12 -1
- data/lib/capybara/spec/session/node_spec.rb +18 -6
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +1 -1
- data/lib/capybara/spec/views/frame_child.erb +2 -1
- data/lib/capybara/spec/views/react.erb +45 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +1 -1
- data/spec/minitest_spec_spec.rb +1 -1
- data/spec/result_spec.rb +10 -6
- data/spec/rspec/shared_spec_matchers.rb +8 -4
- data/spec/selector_spec.rb +4 -0
- data/spec/selenium_spec_safari.rb +2 -3
- data/spec/session_spec.rb +7 -0
- data/spec/shared_selenium_session.rb +14 -11
- data/spec/spec_helper.rb +2 -1
- metadata +6 -16
@@ -38,7 +38,7 @@ Capybara::SpecHelper.spec '#choose' do
|
|
38
38
|
|
39
39
|
context "with a locator that doesn't exist" do
|
40
40
|
it 'should raise an error' do
|
41
|
-
msg =
|
41
|
+
msg = /Unable to find radio button "does not exist"/
|
42
42
|
expect do
|
43
43
|
@session.choose('does not exist')
|
44
44
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
@@ -103,7 +103,7 @@ Capybara::SpecHelper.spec '#choose' do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'should raise error if not allowed to click label' do
|
106
|
-
expect { @session.choose('party_democrat', allow_label_click: false) }.to raise_error(Capybara::ElementNotFound,
|
106
|
+
expect { @session.choose('party_democrat', allow_label_click: false) }.to raise_error(Capybara::ElementNotFound, /Unable to find visible radio button "party_democrat"/)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
@@ -162,6 +162,11 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
162
162
|
expect(extract_results(@session)['first_name']).to eq('John')
|
163
163
|
end
|
164
164
|
|
165
|
+
it 'should submit by specific button id' do
|
166
|
+
@session.click_button(id: 'awe123')
|
167
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
168
|
+
end
|
169
|
+
|
165
170
|
it 'should submit by button title' do
|
166
171
|
@session.click_button('What an Awesome Button')
|
167
172
|
expect(extract_results(@session)['first_name']).to eq('John')
|
@@ -171,6 +176,16 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
171
176
|
@session.click_button('What an Awesome')
|
172
177
|
expect(extract_results(@session)['first_name']).to eq('John')
|
173
178
|
end
|
179
|
+
|
180
|
+
it 'should submit by button name' do
|
181
|
+
@session.click_button('form[awesome]')
|
182
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should submit by specific button name' do
|
186
|
+
@session.click_button(name: 'form[awesome]')
|
187
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
188
|
+
end
|
174
189
|
end
|
175
190
|
|
176
191
|
context 'with fields associated with the form using the form attribute', requires: [:form_attribute] do
|
@@ -314,6 +329,18 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
314
329
|
end
|
315
330
|
end
|
316
331
|
|
332
|
+
context 'with name given on a button defined by <button> tag' do
|
333
|
+
it 'should submit the associated form when name is locator' do
|
334
|
+
@session.click_button('form[no_value]')
|
335
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'should submit the associated form when name is specific' do
|
339
|
+
@session.click_button(name: 'form[no_value]')
|
340
|
+
expect(extract_results(@session)['first_name']).to eq('John')
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
317
344
|
context 'with value given on a button defined by <button> tag' do
|
318
345
|
it 'should submit the associated form' do
|
319
346
|
@session.click_button('click_me')
|
@@ -352,7 +379,7 @@ Capybara::SpecHelper.spec '#click_button' do
|
|
352
379
|
|
353
380
|
context "with a locator that doesn't exist" do
|
354
381
|
it 'should raise an error' do
|
355
|
-
msg =
|
382
|
+
msg = /Unable to find button "does not exist"/
|
356
383
|
expect do
|
357
384
|
@session.click_button('does not exist')
|
358
385
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
@@ -200,7 +200,7 @@ Capybara::SpecHelper.spec '#fill_in' do
|
|
200
200
|
after { Capybara.ignore_hidden_elements = false }
|
201
201
|
|
202
202
|
it 'should not find a hidden field' do
|
203
|
-
msg =
|
203
|
+
msg = /Unable to find visible field "Super Secret"/
|
204
204
|
expect do
|
205
205
|
@session.fill_in('Super Secret', with: '777')
|
206
206
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
@@ -209,7 +209,7 @@ Capybara::SpecHelper.spec '#fill_in' do
|
|
209
209
|
|
210
210
|
context "with a locator that doesn't exist" do
|
211
211
|
it 'should raise an error' do
|
212
|
-
msg =
|
212
|
+
msg = /Unable to find field "does not exist"/
|
213
213
|
expect do
|
214
214
|
@session.fill_in('does not exist', with: 'Blah blah')
|
215
215
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
@@ -53,7 +53,20 @@ Capybara::SpecHelper.spec '#switch_to_frame', requires: [:frames] do
|
|
53
53
|
@session.switch_to_frame frame
|
54
54
|
frame = @session.find(:frame, 'childFrame')
|
55
55
|
@session.switch_to_frame frame
|
56
|
-
@session.click_link 'Close Window'
|
56
|
+
@session.click_link 'Close Window Now'
|
57
|
+
@session.switch_to_frame :parent # Go back to parentFrame
|
58
|
+
expect(@session).to have_selector(:css, 'body#parentBody')
|
59
|
+
expect(@session).not_to have_selector(:css, '#childFrame')
|
60
|
+
@session.switch_to_frame :parent # Go back to top
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'works if the frame is closed with a slight delay', requires: %i[frames js] do
|
64
|
+
frame = @session.find(:frame, 'parentFrame')
|
65
|
+
@session.switch_to_frame frame
|
66
|
+
frame = @session.find(:frame, 'childFrame')
|
67
|
+
@session.switch_to_frame frame
|
68
|
+
@session.click_link 'Close Window Soon'
|
69
|
+
sleep 1
|
57
70
|
@session.switch_to_frame :parent # Go back to parentFrame
|
58
71
|
expect(@session).to have_selector(:css, 'body#parentBody')
|
59
72
|
expect(@session).not_to have_selector(:css, '#childFrame')
|
@@ -92,7 +92,18 @@ Capybara::SpecHelper.spec '#within_frame', requires: [:frames] do
|
|
92
92
|
it 'works if the frame is closed', requires: %i[frames js] do
|
93
93
|
@session.within_frame 'parentFrame' do
|
94
94
|
@session.within_frame 'childFrame' do
|
95
|
-
@session.click_link 'Close Window'
|
95
|
+
@session.click_link 'Close Window Now'
|
96
|
+
end
|
97
|
+
expect(@session).to have_selector(:css, 'body#parentBody')
|
98
|
+
expect(@session).not_to have_selector(:css, '#childFrame')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'works if the frame is closed with a slight delay', requires: %i[frames js] do
|
103
|
+
@session.within_frame 'parentFrame' do
|
104
|
+
@session.within_frame 'childFrame' do
|
105
|
+
@session.click_link 'Close Window Soon'
|
106
|
+
sleep 1
|
96
107
|
end
|
97
108
|
expect(@session).to have_selector(:css, 'body#parentBody')
|
98
109
|
expect(@session).not_to have_selector(:css, '#childFrame')
|
@@ -109,12 +109,24 @@ Capybara::SpecHelper.spec 'node' do
|
|
109
109
|
expect(@session.first('//input').value).to eq('')
|
110
110
|
end
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
if ENV['CAPYBARA_THOROUGH']
|
113
|
+
it 'should raise if the text field is readonly' do
|
114
|
+
expect { @session.first('//input[@readonly]').set('changed') }.to raise_error(Capybara::ReadOnlyElementError)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should raise if the textarea is readonly' do
|
118
|
+
expect { @session.first('//textarea[@readonly]').set('changed') }.to raise_error(Capybara::ReadOnlyElementError)
|
119
|
+
end
|
120
|
+
else
|
121
|
+
it 'should not change if the text field is readonly' do
|
122
|
+
@session.first('//input[@readonly]').set('changed')
|
123
|
+
expect(@session.first('//input[@readonly]').value).to eq 'should not change'
|
124
|
+
end
|
115
125
|
|
116
|
-
|
117
|
-
|
126
|
+
it 'should not change if the textarea is readonly' do
|
127
|
+
@session.first('//textarea[@readonly]').set('changed')
|
128
|
+
expect(@session.first('//textarea[@readonly]').value).to eq 'textarea should not change'
|
129
|
+
end
|
118
130
|
end
|
119
131
|
|
120
132
|
it 'should use global default options' do
|
@@ -183,7 +195,7 @@ Capybara::SpecHelper.spec 'node' do
|
|
183
195
|
|
184
196
|
it 'should see a disabled fieldset as disabled' do
|
185
197
|
@session.visit('/form')
|
186
|
-
expect(@session.find(:
|
198
|
+
expect(@session.find(:xpath, './/fieldset[@id="form_disabled_fieldset"]')).to be_disabled
|
187
199
|
end
|
188
200
|
|
189
201
|
context 'in a disabled fieldset' do
|
@@ -85,11 +85,11 @@ Capybara::SpecHelper.spec '#uncheck' do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'should raise original error when no label available' do
|
88
|
-
expect { @session.uncheck('form_cars_porsche') }.to raise_error(Capybara::ElementNotFound,
|
88
|
+
expect { @session.uncheck('form_cars_porsche') }.to raise_error(Capybara::ElementNotFound, /Unable to find visible checkbox "form_cars_porsche"/)
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should raise error if not allowed to click label' do
|
92
|
-
expect { @session.uncheck('form_cars_jaguar', allow_label_click: false) }.to raise_error(Capybara::ElementNotFound,
|
92
|
+
expect { @session.uncheck('form_cars_jaguar', allow_label_click: false) }.to raise_error(Capybara::ElementNotFound, /Unable to find visible checkbox "form_cars_jaguar"/)
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'should include node filter description in error if necessary' do
|
@@ -56,7 +56,7 @@ Capybara::SpecHelper.spec '#unselect' do
|
|
56
56
|
|
57
57
|
context "with a locator that doesn't exist" do
|
58
58
|
it 'should raise an error' do
|
59
|
-
msg =
|
59
|
+
msg = /Unable to find select box "does not exist"/
|
60
60
|
expect do
|
61
61
|
@session.unselect('foo', from: 'does not exist')
|
62
62
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
@@ -10,7 +10,8 @@
|
|
10
10
|
</script>
|
11
11
|
</head>
|
12
12
|
<body id="childBody">
|
13
|
-
<a href="javascript:void(0)" onClick="closeWin()">Close Window</a>
|
13
|
+
<a href="javascript:void(0)" onClick="closeWin()">Close Window Now</a>
|
14
|
+
<a href="javascript:void(0)" onClick="setTimeout(function(){closeWin()}, 10)">Close Window Soon</a>
|
14
15
|
<iframe src="/frame_one" id="grandchildFrame1"></iframe>
|
15
16
|
<iframe src="/frame_two" id="grandchildFrame2"></iframe>
|
16
17
|
</body>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<script src="https://unpkg.com/react/umd/react.development.js"></script>
|
5
|
+
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="root"></div>
|
9
|
+
<script>
|
10
|
+
// https://codepen.io/gaearon/pen/VmmPgp?editors=0010
|
11
|
+
class NameForm extends React.Component {
|
12
|
+
constructor(props) {
|
13
|
+
super(props);
|
14
|
+
this.state = { value: '' };
|
15
|
+
|
16
|
+
this.handleChange = this.handleChange.bind(this);
|
17
|
+
this.handleSubmit = this.handleSubmit.bind(this);
|
18
|
+
}
|
19
|
+
|
20
|
+
handleChange(event) {
|
21
|
+
this.setState({ value: event.target.value });
|
22
|
+
}
|
23
|
+
|
24
|
+
handleSubmit(event) {
|
25
|
+
alert('A name was submitted: ' + this.state.value);
|
26
|
+
event.preventDefault();
|
27
|
+
}
|
28
|
+
|
29
|
+
render() {
|
30
|
+
return (
|
31
|
+
React.createElement("form", { onSubmit: this.handleSubmit },
|
32
|
+
React.createElement("label", null, "Name:",
|
33
|
+
|
34
|
+
React.createElement("input", { type: "text", value: this.state.value, onChange: this.handleChange })),
|
35
|
+
|
36
|
+
React.createElement("input", { type: "submit", value: "Submit" })));
|
37
|
+
}}
|
38
|
+
|
39
|
+
|
40
|
+
ReactDOM.render(
|
41
|
+
React.createElement(NameForm, null),
|
42
|
+
document.getElementById('root'));
|
43
|
+
</script>
|
44
|
+
</body>
|
45
|
+
</html>
|
data/lib/capybara/version.rb
CHANGED
data/lib/capybara/window.rb
CHANGED
@@ -49,7 +49,7 @@ module Capybara
|
|
49
49
|
# @return [Boolean] whether this window is the window in which commands are being executed
|
50
50
|
def current?
|
51
51
|
@driver.current_window_handle == @handle
|
52
|
-
rescue @driver.no_such_window_error
|
52
|
+
rescue @driver.no_such_window_error # rubocop:disable Naming/RescuedExceptionsVariableName
|
53
53
|
false
|
54
54
|
end
|
55
55
|
|
data/spec/minitest_spec_spec.rb
CHANGED
@@ -146,6 +146,6 @@ RSpec.describe 'capybara/minitest/spec' do
|
|
146
146
|
reporter.report
|
147
147
|
expect(output.string).to include('20 runs, 42 assertions, 1 failures, 0 errors, 1 skips')
|
148
148
|
# Make sure error messages are displayed
|
149
|
-
expect(output.string).to
|
149
|
+
expect(output.string).to match(/expected to find select box "non_existing_form_title" .*but there were no matches/)
|
150
150
|
end
|
151
151
|
end
|
data/spec/result_spec.rb
CHANGED
@@ -106,7 +106,7 @@ RSpec.describe Capybara::Result do
|
|
106
106
|
|
107
107
|
# Not a great test but it indirectly tests what is needed
|
108
108
|
it 'should evaluate filters lazily for idx' do
|
109
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
109
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
110
110
|
# Not processed until accessed
|
111
111
|
expect(result.instance_variable_get('@result_cache').size).to be 0
|
112
112
|
|
@@ -127,7 +127,7 @@ RSpec.describe Capybara::Result do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'should evaluate filters lazily for range' do
|
130
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
130
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
131
131
|
result[0..1]
|
132
132
|
expect(result.instance_variable_get('@result_cache').size).to be 2
|
133
133
|
|
@@ -136,7 +136,7 @@ RSpec.describe Capybara::Result do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
it 'should evaluate filters lazily for idx and length' do
|
139
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
139
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
140
140
|
result[1, 2]
|
141
141
|
expect(result.instance_variable_get('@result_cache').size).to be 3
|
142
142
|
|
@@ -145,7 +145,7 @@ RSpec.describe Capybara::Result do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
it 'should only need to evaluate one result for any?' do
|
148
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
148
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
149
149
|
result.any?
|
150
150
|
expect(result.instance_variable_get('@result_cache').size).to be 1
|
151
151
|
end
|
@@ -158,7 +158,7 @@ RSpec.describe Capybara::Result do
|
|
158
158
|
|
159
159
|
context '#each' do
|
160
160
|
it 'lazily evaluates' do
|
161
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
161
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
162
162
|
results = []
|
163
163
|
result.each do |el|
|
164
164
|
results << el
|
@@ -174,7 +174,7 @@ RSpec.describe Capybara::Result do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'lazily evaluates' do
|
177
|
-
skip 'JRuby has an issue with lazy enumerator evaluation' if
|
177
|
+
skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
|
178
178
|
result.each.with_index do |_el, idx|
|
179
179
|
expect(result.instance_variable_get('@result_cache').size).to eq(idx + 1) # 0 indexing
|
180
180
|
end
|
@@ -197,4 +197,8 @@ RSpec.describe Capybara::Result do
|
|
197
197
|
expect(eval_count).to eq 1
|
198
198
|
end
|
199
199
|
end
|
200
|
+
|
201
|
+
def jruby_lazy_enumerator_workaround?
|
202
|
+
(RUBY_PLATFORM == 'java') && (Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.2.8.0'))
|
203
|
+
end
|
200
204
|
end
|
@@ -627,8 +627,12 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
|
627
627
|
describe 'have_button matcher' do
|
628
628
|
let(:html) { '<button>A button</button><input type="submit" value="Another button"/>' }
|
629
629
|
|
630
|
-
it 'gives proper description' do
|
631
|
-
expect(have_button('A button').description).to eq('have visible button "A button"')
|
630
|
+
it 'gives proper description with no options' do
|
631
|
+
expect(have_button('A button').description).to eq('have visible button "A button" that is not disabled')
|
632
|
+
end
|
633
|
+
|
634
|
+
it 'gives proper description with disabled :any option' do
|
635
|
+
expect(have_button('A button', disabled: :all).description).to eq('have visible button "A button"')
|
632
636
|
end
|
633
637
|
|
634
638
|
it 'passes if there is such a button' do
|
@@ -698,7 +702,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
|
698
702
|
end
|
699
703
|
|
700
704
|
it 'gives proper description' do
|
701
|
-
expect(have_checked_field('it is checked').description).to eq('have visible field "it is checked" that is
|
705
|
+
expect(have_checked_field('it is checked').description).to eq('have visible field "it is checked" that is not disabled that is checked')
|
702
706
|
end
|
703
707
|
|
704
708
|
context 'with should' do
|
@@ -747,7 +751,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
|
|
747
751
|
end
|
748
752
|
|
749
753
|
it 'gives proper description' do
|
750
|
-
expect(have_unchecked_field('unchecked field').description).to eq('have visible field "unchecked field" that is not
|
754
|
+
expect(have_unchecked_field('unchecked field').description).to eq('have visible field "unchecked field" that is not disabled that is not checked')
|
751
755
|
end
|
752
756
|
|
753
757
|
context 'with should' do
|
data/spec/selector_spec.rb
CHANGED
@@ -478,6 +478,10 @@ RSpec.describe Capybara do
|
|
478
478
|
Capybara::Selector[:link_or_button].expression_filters.delete(:random)
|
479
479
|
end
|
480
480
|
|
481
|
+
it 'should not find links when disabled == true' do
|
482
|
+
expect(string.all(:link_or_button, disabled: true).size).to eq 0
|
483
|
+
end
|
484
|
+
|
481
485
|
context 'when modified' do
|
482
486
|
it 'should still work' do
|
483
487
|
filter = Capybara::Selector[:link_or_button].expression_filters[:random]
|
@@ -57,10 +57,9 @@ Capybara::SpecHelper.run_specs TestSessions::Safari, SAFARI_DRIVER.to_s, capybar
|
|
57
57
|
'Capybara::Session selenium_safari node #click should allow to retry longer',
|
58
58
|
'Capybara::Session selenium_safari node #click should retry clicking'
|
59
59
|
pending "safaridriver doesn't return a specific enough error to deal with this"
|
60
|
-
when /Capybara::Session selenium_safari #within_frame
|
61
|
-
/Capybara::Session selenium_safari #within_frame works if the frame is closed/,
|
60
|
+
when /Capybara::Session selenium_safari #within_frame works if the frame is closed/,
|
62
61
|
/Capybara::Session selenium_safari #switch_to_frame works if the frame is closed/
|
63
|
-
skip '
|
62
|
+
skip 'Safari has a race condition when clicking an element that causes the frame to close. It will sometimes raise a NoSuchFrameError'
|
64
63
|
when /Capybara::Session selenium_safari #reset_session! removes ALL cookies/
|
65
64
|
skip 'Safari webdriver can only remove cookies for the current domain'
|
66
65
|
when /Capybara::Session selenium_safari #refresh it reposts/
|
data/spec/session_spec.rb
CHANGED
@@ -80,5 +80,12 @@ RSpec.describe Capybara::Session do
|
|
80
80
|
session.quit
|
81
81
|
expect(session.driver).not_to eql driver
|
82
82
|
end
|
83
|
+
|
84
|
+
it 'resets the document' do
|
85
|
+
session = Capybara::Session.new(:rack_test, TestApp)
|
86
|
+
document = session.document
|
87
|
+
session.quit
|
88
|
+
expect(session.document.base).not_to eql document.base
|
89
|
+
end
|
83
90
|
end
|
84
91
|
end
|
@@ -472,18 +472,21 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|
472
472
|
describe 'with react' do
|
473
473
|
context 'controlled components' do
|
474
474
|
it 'can set and clear a text field' do
|
475
|
-
session.visit 'https://reactjs.org/docs/forms.html'
|
476
|
-
session.all(:css, 'h2#controlled-components ~ p a', text: 'Try it on CodePen')[0].click
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
session.
|
484
|
-
|
485
|
-
|
475
|
+
# session.visit 'https://reactjs.org/docs/forms.html'
|
476
|
+
# session.all(:css, 'h2#controlled-components ~ p a', text: 'Try it on CodePen')[0].click
|
477
|
+
# copied into local view
|
478
|
+
session.visit 'react'
|
479
|
+
# Not necessary when accessed locally
|
480
|
+
# session.within_frame(:css, 'iframe.result-iframe:not([src=""])', wait: 10) do
|
481
|
+
session.fill_in('Name:', with: 'abc')
|
482
|
+
session.accept_prompt 'A name was submitted: abc' do
|
483
|
+
session.click_button('Submit')
|
484
|
+
end
|
485
|
+
session.fill_in('Name:', with: '')
|
486
|
+
session.accept_prompt(/A name was submitted: $/) do
|
487
|
+
session.click_button('Submit')
|
486
488
|
end
|
489
|
+
# end
|
487
490
|
end
|
488
491
|
end
|
489
492
|
end
|