capybara 3.0.3 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +10 -0
- data/lib/capybara.rb +1 -1
- data/lib/capybara/helpers.rb +1 -1
- data/lib/capybara/minitest/spec.rb +2 -0
- data/lib/capybara/node/actions.rb +45 -5
- data/lib/capybara/queries/match_query.rb +2 -0
- data/lib/capybara/queries/selector_query.rb +3 -4
- data/lib/capybara/queries/text_query.rb +4 -5
- data/lib/capybara/rack_test/node.rb +6 -4
- data/lib/capybara/result.rb +1 -1
- data/lib/capybara/rspec/compound.rb +2 -0
- data/lib/capybara/selector.rb +72 -18
- data/lib/capybara/selector/css.rb +2 -0
- data/lib/capybara/selenium/driver.rb +14 -15
- data/lib/capybara/selenium/node.rb +23 -29
- data/lib/capybara/server.rb +29 -4
- data/lib/capybara/session.rb +12 -13
- data/lib/capybara/spec/session/all_spec.rb +6 -6
- data/lib/capybara/spec/session/{assert_current_path.rb → assert_current_path_spec.rb} +2 -3
- data/lib/capybara/spec/session/{assert_selector.rb → assert_selector_spec.rb} +0 -0
- data/lib/capybara/spec/session/{assert_text.rb → assert_text_spec.rb} +1 -1
- data/lib/capybara/spec/session/{assert_title.rb → assert_title_spec.rb} +0 -0
- data/lib/capybara/spec/session/check_spec.rb +6 -6
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +0 -7
- data/lib/capybara/spec/session/current_url_spec.rb +6 -8
- data/lib/capybara/spec/session/element/{assert_match_selector.rb → assert_match_selector_spec.rb} +2 -0
- data/lib/capybara/spec/session/element/match_css_spec.rb +2 -0
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +2 -0
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +2 -0
- data/lib/capybara/spec/session/find_by_id_spec.rb +1 -1
- data/lib/capybara/spec/session/find_field_spec.rb +1 -1
- data/lib/capybara/spec/session/first_spec.rb +12 -12
- data/lib/capybara/spec/session/frame/frame_title_spec.rb +1 -1
- data/lib/capybara/spec/session/frame/frame_url_spec.rb +1 -1
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +2 -2
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +1 -1
- data/lib/capybara/spec/session/has_button_spec.rb +5 -0
- data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
- data/lib/capybara/spec/session/has_field_spec.rb +1 -1
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +2 -0
- data/lib/capybara/spec/session/has_selector_spec.rb +8 -0
- data/lib/capybara/spec/session/{headers.rb → headers_spec.rb} +0 -0
- data/lib/capybara/spec/session/node_spec.rb +4 -4
- data/lib/capybara/spec/session/reset_session_spec.rb +2 -2
- data/lib/capybara/spec/session/{response_code.rb → response_code_spec.rb} +0 -0
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -1
- data/lib/capybara/spec/session/select_spec.rb +27 -1
- data/lib/capybara/spec/session/selectors_spec.rb +2 -0
- data/lib/capybara/spec/session/uncheck_spec.rb +3 -3
- data/lib/capybara/spec/session/visit_spec.rb +17 -10
- data/lib/capybara/spec/session/window/become_closed_spec.rb +3 -3
- data/lib/capybara/spec/session/window/current_window_spec.rb +2 -2
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +3 -3
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +5 -5
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +3 -3
- data/lib/capybara/spec/session/window/window_spec.rb +24 -9
- data/lib/capybara/spec/session/window/windows_spec.rb +2 -2
- data/lib/capybara/spec/session/window/within_window_spec.rb +2 -2
- data/lib/capybara/spec/session/within_spec.rb +3 -3
- data/lib/capybara/spec/spec_helper.rb +7 -5
- data/lib/capybara/spec/views/form.erb +9 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +1 -1
- data/spec/capybara_spec.rb +4 -14
- data/spec/dsl_spec.rb +5 -3
- data/spec/fixtures/certificate.pem +25 -0
- data/spec/fixtures/key.pem +27 -0
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
- data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
- data/spec/rack_test_spec.rb +8 -6
- data/spec/result_spec.rb +22 -2
- data/spec/rspec/features_spec.rb +4 -2
- data/spec/rspec/scenarios_spec.rb +1 -1
- data/spec/rspec/shared_spec_matchers.rb +7 -4
- data/spec/rspec/views_spec.rb +2 -1
- data/spec/rspec_spec.rb +80 -78
- data/spec/selenium_spec_marionette.rb +6 -4
- data/spec/server_spec.rb +40 -2
- data/spec/session_spec.rb +12 -4
- data/spec/shared_selenium_session.rb +106 -84
- metadata +11 -9
data/lib/capybara/server.rb
CHANGED
@@ -61,10 +61,14 @@ module Capybara
|
|
61
61
|
|
62
62
|
attr_reader :app, :port, :host
|
63
63
|
|
64
|
-
def initialize(app, port
|
64
|
+
def initialize(app, *deprecated_options, port: Capybara.server_port, host: Capybara.server_host, reportable_errors: Capybara.server_errors)
|
65
|
+
warn "Positional arguments, other than the application, to Server#new are deprecated, please use keyword arguments" unless deprecated_options.empty?
|
65
66
|
@app = app
|
66
67
|
@server_thread = nil # suppress warnings
|
67
|
-
@host
|
68
|
+
@host = deprecated_options[1] || host
|
69
|
+
@reportable_errors = deprecated_options[2] || reportable_errors
|
70
|
+
@using_ssl = false
|
71
|
+
@port = deprecated_options[0] || port
|
68
72
|
@port ||= Capybara::Server.ports[port_key]
|
69
73
|
@port ||= find_available_port(host)
|
70
74
|
end
|
@@ -77,10 +81,23 @@ module Capybara
|
|
77
81
|
middleware.error
|
78
82
|
end
|
79
83
|
|
84
|
+
def using_ssl?
|
85
|
+
@using_ssl
|
86
|
+
end
|
87
|
+
|
80
88
|
def responsive?
|
81
89
|
return false if @server_thread && @server_thread.join(0)
|
82
90
|
|
83
|
-
|
91
|
+
begin
|
92
|
+
res = if !@using_ssl
|
93
|
+
http_connect
|
94
|
+
else
|
95
|
+
https_connect
|
96
|
+
end
|
97
|
+
rescue EOFError, Net::ReadTimeout
|
98
|
+
res = https_connect
|
99
|
+
@using_ssl = true
|
100
|
+
end
|
84
101
|
|
85
102
|
if res.is_a?(Net::HTTPSuccess) or res.is_a?(Net::HTTPRedirection)
|
86
103
|
return res.body == app.object_id.to_s
|
@@ -121,8 +138,16 @@ module Capybara
|
|
121
138
|
|
122
139
|
private
|
123
140
|
|
141
|
+
def http_connect
|
142
|
+
Net::HTTP.start(host, port, read_timeout: 2) { |http| http.get('/__identify__') }
|
143
|
+
end
|
144
|
+
|
145
|
+
def https_connect
|
146
|
+
Net::HTTP.start(host, port, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |http| http.get('/__identify__') }
|
147
|
+
end
|
148
|
+
|
124
149
|
def middleware
|
125
|
-
@middleware ||= Middleware.new(app, @
|
150
|
+
@middleware ||= Middleware.new(app, @reportable_errors)
|
126
151
|
end
|
127
152
|
|
128
153
|
def port_key
|
data/lib/capybara/session.rb
CHANGED
@@ -84,7 +84,7 @@ module Capybara
|
|
84
84
|
yield config
|
85
85
|
end
|
86
86
|
@server = if config.run_server and @app and driver.needs_server?
|
87
|
-
Capybara::Server.new(@app, config.server_port, config.server_host, config.server_errors).boot
|
87
|
+
Capybara::Server.new(@app, port: config.server_port, host: config.server_host, reportable_errors: config.server_errors).boot
|
88
88
|
else
|
89
89
|
nil
|
90
90
|
end
|
@@ -137,18 +137,17 @@ module Capybara
|
|
137
137
|
# Raise errors encountered in the server
|
138
138
|
#
|
139
139
|
def raise_server_error!
|
140
|
-
if @server
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
end
|
146
|
-
rescue CapybaraError
|
147
|
-
# needed to get the cause set correctly in JRuby -- otherwise we could just do raise @server.error
|
148
|
-
raise @server.error, @server.error.message, @server.error.backtrace
|
149
|
-
ensure
|
150
|
-
@server.reset_error!
|
140
|
+
return if @server.nil? || !@server.error
|
141
|
+
# Force an explanation for the error being raised as the exception cause
|
142
|
+
begin
|
143
|
+
if config.raise_server_errors
|
144
|
+
raise CapybaraError, "Your application server raised an error - It has been raised in your test code because Capybara.raise_server_errors == true"
|
151
145
|
end
|
146
|
+
rescue CapybaraError
|
147
|
+
# needed to get the cause set correctly in JRuby -- otherwise we could just do raise @server.error
|
148
|
+
raise @server.error, @server.error.message, @server.error.backtrace
|
149
|
+
ensure
|
150
|
+
@server.reset_error!
|
152
151
|
end
|
153
152
|
end
|
154
153
|
|
@@ -250,7 +249,7 @@ module Capybara
|
|
250
249
|
visit_uri = ::Addressable::URI.parse(visit_uri.to_s)
|
251
250
|
|
252
251
|
uri_base = if @server
|
253
|
-
::Addressable::URI.parse(config.app_host || "http://#{@server.host}:#{@server.port}")
|
252
|
+
::Addressable::URI.parse(config.app_host || "http#{'s' if @server.using_ssl?}://#{@server.host}:#{@server.port}")
|
254
253
|
else
|
255
254
|
config.app_host && ::Addressable::URI.parse(config.app_host)
|
256
255
|
end
|
@@ -96,7 +96,7 @@ Capybara::SpecHelper.spec "#all" do
|
|
96
96
|
context 'with element count filters' do
|
97
97
|
context ':count' do
|
98
98
|
it 'should succeed when the number of elements founds matches the expectation' do
|
99
|
-
expect { @session.all(:css, 'h1, p', count: 4) }.
|
99
|
+
expect { @session.all(:css, 'h1, p', count: 4) }.not_to raise_error
|
100
100
|
end
|
101
101
|
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
102
102
|
expect { @session.all(:css, 'h1, p', count: 5) }.to raise_error(Capybara::ExpectationNotMet)
|
@@ -104,7 +104,7 @@ Capybara::SpecHelper.spec "#all" do
|
|
104
104
|
end
|
105
105
|
context ':minimum' do
|
106
106
|
it 'should succeed when the number of elements founds matches the expectation' do
|
107
|
-
expect { @session.all(:css, 'h1, p', minimum: 0) }.
|
107
|
+
expect { @session.all(:css, 'h1, p', minimum: 0) }.not_to raise_error
|
108
108
|
end
|
109
109
|
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
110
110
|
expect { @session.all(:css, 'h1, p', minimum: 5) }.to raise_error(Capybara::ExpectationNotMet)
|
@@ -112,7 +112,7 @@ Capybara::SpecHelper.spec "#all" do
|
|
112
112
|
end
|
113
113
|
context ':maximum' do
|
114
114
|
it 'should succeed when the number of elements founds matches the expectation' do
|
115
|
-
expect { @session.all(:css, 'h1, p', maximum: 4) }.
|
115
|
+
expect { @session.all(:css, 'h1, p', maximum: 4) }.not_to raise_error
|
116
116
|
end
|
117
117
|
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
118
118
|
expect { @session.all(:css, 'h1, p', maximum: 0) }.to raise_error(Capybara::ExpectationNotMet)
|
@@ -120,7 +120,7 @@ Capybara::SpecHelper.spec "#all" do
|
|
120
120
|
end
|
121
121
|
context ':between' do
|
122
122
|
it 'should succeed when the number of elements founds matches the expectation' do
|
123
|
-
expect { @session.all(:css, 'h1, p', between: 2..7) }.
|
123
|
+
expect { @session.all(:css, 'h1, p', between: 2..7) }.not_to raise_error
|
124
124
|
end
|
125
125
|
it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
|
126
126
|
expect { @session.all(:css, 'h1, p', between: 0..3) }.to raise_error(Capybara::ExpectationNotMet)
|
@@ -133,7 +133,7 @@ Capybara::SpecHelper.spec "#all" do
|
|
133
133
|
minimum: 5,
|
134
134
|
maximum: 0,
|
135
135
|
between: 0..3 }
|
136
|
-
expect { @session.all(:css, 'h1, p', o) }.
|
136
|
+
expect { @session.all(:css, 'h1, p', o) }.not_to raise_error
|
137
137
|
end
|
138
138
|
context 'with no :count expectation' do
|
139
139
|
it 'fails if :minimum is not met' do
|
@@ -158,7 +158,7 @@ Capybara::SpecHelper.spec "#all" do
|
|
158
158
|
o = { minimum: 0,
|
159
159
|
maximum: 4,
|
160
160
|
between: 2..7 }
|
161
|
-
expect { @session.all(:css, 'h1, p', o) }.
|
161
|
+
expect { @session.all(:css, 'h1, p', o) }.not_to raise_error
|
162
162
|
end
|
163
163
|
end
|
164
164
|
end
|
@@ -37,8 +37,7 @@ Capybara::SpecHelper.spec '#assert_current_path' do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should not cause an exception when current_url is nil" do
|
40
|
-
allow_any_instance_of(Capybara::Session).to receive(:current_url)
|
41
|
-
|
40
|
+
allow_any_instance_of(Capybara::Session).to receive(:current_url).and_return(nil)
|
42
41
|
expect { @session.assert_current_path(nil) }.not_to raise_error
|
43
42
|
end
|
44
43
|
end
|
@@ -66,7 +65,7 @@ Capybara::SpecHelper.spec '#assert_no_current_path?' do
|
|
66
65
|
end
|
67
66
|
|
68
67
|
it "should not cause an exception when current_url is nil" do
|
69
|
-
allow_any_instance_of(Capybara::Session).to receive(:current_url)
|
68
|
+
allow_any_instance_of(Capybara::Session).to receive(:current_url).and_return(nil)
|
70
69
|
|
71
70
|
expect { @session.assert_no_current_path('/with_html') }.not_to raise_error
|
72
71
|
end
|
File without changes
|
File without changes
|
@@ -128,21 +128,21 @@ Capybara::SpecHelper.spec "#check" do
|
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should check via clicking the label with :for attribute if possible" do
|
131
|
-
expect(@session.find(:checkbox, 'form_cars_tesla', unchecked: true, visible: :hidden)).to
|
131
|
+
expect(@session.find(:checkbox, 'form_cars_tesla', unchecked: true, visible: :hidden)).to be_truthy
|
132
132
|
@session.check('form_cars_tesla')
|
133
133
|
@session.click_button('awesome')
|
134
134
|
expect(extract_results(@session)['cars']).to include('tesla')
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should check via clicking the wrapping label if possible" do
|
138
|
-
expect(@session.find(:checkbox, 'form_cars_mclaren', unchecked: true, visible: :hidden)).to
|
138
|
+
expect(@session.find(:checkbox, 'form_cars_mclaren', unchecked: true, visible: :hidden)).to be_truthy
|
139
139
|
@session.check('form_cars_mclaren')
|
140
140
|
@session.click_button('awesome')
|
141
141
|
expect(extract_results(@session)['cars']).to include('mclaren')
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should not click the label if unneeded" do
|
145
|
-
expect(@session.find(:checkbox, 'form_cars_jaguar', checked: true, visible: :hidden)).to
|
145
|
+
expect(@session.find(:checkbox, 'form_cars_jaguar', checked: true, visible: :hidden)).to be_truthy
|
146
146
|
@session.check('form_cars_jaguar')
|
147
147
|
@session.click_button('awesome')
|
148
148
|
expect(extract_results(@session)['cars']).to include('jaguar')
|
@@ -170,14 +170,14 @@ Capybara::SpecHelper.spec "#check" do
|
|
170
170
|
|
171
171
|
context "with allow_label_click == true" do
|
172
172
|
it "should check via the label if input is hidden" do
|
173
|
-
expect(@session.find(:checkbox, 'form_cars_tesla', unchecked: true, visible: :hidden)).to
|
173
|
+
expect(@session.find(:checkbox, 'form_cars_tesla', unchecked: true, visible: :hidden)).to be_truthy
|
174
174
|
@session.check('form_cars_tesla', allow_label_click: true)
|
175
175
|
@session.click_button('awesome')
|
176
176
|
expect(extract_results(@session)['cars']).to include('tesla')
|
177
177
|
end
|
178
178
|
|
179
179
|
it "should not wait the full time if label can be clicked" do
|
180
|
-
expect(@session.find(:checkbox, 'form_cars_tesla', unchecked: true, visible: :hidden)).to
|
180
|
+
expect(@session.find(:checkbox, 'form_cars_tesla', unchecked: true, visible: :hidden)).to be_truthy
|
181
181
|
start_time = Time.now
|
182
182
|
@session.check('form_cars_tesla', allow_label_click: true, wait: 10)
|
183
183
|
end_time = Time.now
|
@@ -185,7 +185,7 @@ Capybara::SpecHelper.spec "#check" do
|
|
185
185
|
end
|
186
186
|
|
187
187
|
it "should check via the label if input is moved off the left edge of the page" do
|
188
|
-
expect(@session.find(:checkbox, 'form_cars_pagani', unchecked: true, visible: :all)).to
|
188
|
+
expect(@session.find(:checkbox, 'form_cars_pagani', unchecked: true, visible: :all)).to be_truthy
|
189
189
|
@session.check('form_cars_pagani', allow_label_click: true)
|
190
190
|
@session.click_button('awesome')
|
191
191
|
expect(extract_results(@session)['cars']).to include('pagani')
|
@@ -102,13 +102,6 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
|
|
102
102
|
@session.click_link_or_button('Disabled link')
|
103
103
|
expect(@session).to have_content("Bar")
|
104
104
|
end
|
105
|
-
|
106
|
-
it "does nothing when button is disabled" do
|
107
|
-
@session.visit('/form')
|
108
|
-
expect do
|
109
|
-
@session.click_link_or_button('Disabled button', disabled: false)
|
110
|
-
end.to raise_error(Capybara::ElementNotFound)
|
111
|
-
end
|
112
105
|
end
|
113
106
|
|
114
107
|
it "should return the element clicked" do
|
@@ -3,11 +3,11 @@
|
|
3
3
|
require "capybara/spec/test_app"
|
4
4
|
|
5
5
|
Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
|
6
|
-
before :all do
|
6
|
+
before :all do # rubocop:disable RSpec/BeforeAfterAll
|
7
7
|
@servers = Array.new(2) { Capybara::Server.new(TestApp.new).boot }
|
8
8
|
# sanity check
|
9
|
-
expect(@servers[0].port).not_to eq(@servers[1].port)
|
10
|
-
expect(@servers.map(&:port)).not_to include 80
|
9
|
+
expect(@servers[0].port).not_to eq(@servers[1].port) # rubocop:disable RSpec/ExpectInHook
|
10
|
+
expect(@servers.map(&:port)).not_to include 80 # rubocop:disable RSpec/ExpectInHook
|
11
11
|
end
|
12
12
|
|
13
13
|
def bases
|
@@ -23,10 +23,8 @@ Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
|
|
23
23
|
expect(@session.current_url.chomp('?')).to eq("#{scheme}://#{s.host}:#{s.port}#{path}")
|
24
24
|
expect(@session.current_host).to eq("#{scheme}://#{s.host}") # no port
|
25
25
|
expect(@session.current_path).to eq(path)
|
26
|
-
|
27
|
-
|
28
|
-
expect(@session).to have_content("Current host is #{scheme}://#{s.host}:#{s.port}")
|
29
|
-
end
|
26
|
+
# Server should agree with us
|
27
|
+
expect(@session).to have_content("Current host is #{scheme}://#{s.host}:#{s.port}") if path == '/host'
|
30
28
|
end
|
31
29
|
|
32
30
|
def visit_host_links
|
@@ -100,7 +98,7 @@ Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
|
|
100
98
|
|
101
99
|
it "doesn't raise exception on a nil current_url" do
|
102
100
|
skip "Only makes sense when there is a real driver" unless @session.respond_to?(:driver)
|
103
|
-
allow(@session.driver).to receive(:current_url)
|
101
|
+
allow(@session.driver).to receive(:current_url).and_return(nil)
|
104
102
|
@session.visit("/")
|
105
103
|
expect { @session.current_url }.not_to raise_exception
|
106
104
|
expect { @session.current_path }.not_to raise_exception
|
@@ -24,7 +24,7 @@ Capybara::SpecHelper.spec '#find_by_id' do
|
|
24
24
|
expect(@session.find_by_id("hidden_via_ancestor", visible: false).text(:all)).to match(/with hidden ancestor/)
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "doesn't find invisible elements when `true`" do
|
28
28
|
expect do
|
29
29
|
@session.find_by_id("hidden_via_ancestor", visible: true)
|
30
30
|
end.to raise_error(Capybara::ElementNotFound)
|
@@ -9,7 +9,7 @@ Capybara::SpecHelper.spec '#find_field' do
|
|
9
9
|
expect(@session.find_field('Dog').value).to eq('dog')
|
10
10
|
expect(@session.find_field('form_description').value).to eq('Descriptive text goes here')
|
11
11
|
expect(@session.find_field('Region')[:name]).to eq('form[region]')
|
12
|
-
expect(@session.find_field('With Asterisk*')).to
|
12
|
+
expect(@session.find_field('With Asterisk*')).to be_truthy
|
13
13
|
end
|
14
14
|
|
15
15
|
context "aria_label attribute with Capybara.enable_aria_label" do
|
@@ -65,20 +65,20 @@ Capybara::SpecHelper.spec '#first' do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should find nodes regardless of whether they are invisible when false" do
|
68
|
-
expect(@session.first(:css, "a#invisible", visible: false)).to
|
69
|
-
expect(@session.first(:css, "a#invisible", visible: false, text: 'hidden link')).to
|
70
|
-
expect(@session.first(:css, "a#visible", visible: false)).to
|
68
|
+
expect(@session.first(:css, "a#invisible", visible: false)).to be_truthy
|
69
|
+
expect(@session.first(:css, "a#invisible", visible: false, text: 'hidden link')).to be_truthy
|
70
|
+
expect(@session.first(:css, "a#visible", visible: false)).to be_truthy
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should find nodes regardless of whether they are invisible when :all" do
|
74
|
-
expect(@session.first(:css, "a#invisible", visible: :all)).to
|
75
|
-
expect(@session.first(:css, "a#invisible", visible: :all, text: 'hidden link')).to
|
76
|
-
expect(@session.first(:css, "a#visible", visible: :all)).to
|
74
|
+
expect(@session.first(:css, "a#invisible", visible: :all)).to be_truthy
|
75
|
+
expect(@session.first(:css, "a#invisible", visible: :all, text: 'hidden link')).to be_truthy
|
76
|
+
expect(@session.first(:css, "a#visible", visible: :all)).to be_truthy
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should find only hidden nodes when :hidden" do
|
80
|
-
expect(@session.first(:css, "a#invisible", visible: :hidden)).to
|
81
|
-
expect(@session.first(:css, "a#invisible", visible: :hidden, text: 'hidden link')).to
|
80
|
+
expect(@session.first(:css, "a#invisible", visible: :hidden)).to be_truthy
|
81
|
+
expect(@session.first(:css, "a#invisible", visible: :hidden, text: 'hidden link')).to be_truthy
|
82
82
|
expect do
|
83
83
|
@session.first(:css, "a#invisible", visible: :hidden, text: 'not hidden link')
|
84
84
|
end.to raise_error Capybara::ElementNotFound
|
@@ -94,7 +94,7 @@ Capybara::SpecHelper.spec '#first' do
|
|
94
94
|
expect do
|
95
95
|
@session.first(:css, "a#invisible", visible: :visible, text: 'hidden link')
|
96
96
|
end.to raise_error Capybara::ElementNotFound
|
97
|
-
expect(@session.first(:css, "a#visible", visible: :visible)).to
|
97
|
+
expect(@session.first(:css, "a#visible", visible: :visible)).to be_truthy
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should default to Capybara.ignore_hidden_elements" do
|
@@ -103,8 +103,8 @@ Capybara::SpecHelper.spec '#first' do
|
|
103
103
|
@session.first(:css, "a#invisible")
|
104
104
|
end.to raise_error Capybara::ElementNotFound
|
105
105
|
Capybara.ignore_hidden_elements = false
|
106
|
-
expect(@session.first(:css, "a#invisible")).to
|
107
|
-
expect(@session.first(:css, "a")).to
|
106
|
+
expect(@session.first(:css, "a#invisible")).to be_truthy
|
107
|
+
expect(@session.first(:css, "a")).to be_truthy
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -115,7 +115,7 @@ Capybara::SpecHelper.spec '#first' do
|
|
115
115
|
|
116
116
|
it "should find the first element using the given locator" do
|
117
117
|
@session.within(:xpath, "//div[@id='for_bar']") do
|
118
|
-
expect(@session.first('.//form')).to
|
118
|
+
expect(@session.first('.//form')).to be_truthy
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Capybara::SpecHelper.spec '#switch_to_frame', requires: [:frames] do
|
4
|
-
before
|
4
|
+
before do
|
5
5
|
@session.visit('/within_frames')
|
6
6
|
end
|
7
7
|
|
8
|
-
after
|
8
|
+
after do
|
9
9
|
# Ensure we clean up after the frame changes
|
10
10
|
@session.switch_to_frame(:top)
|
11
11
|
end
|
@@ -34,6 +34,11 @@ Capybara::SpecHelper.spec '#has_button?' do
|
|
34
34
|
it "should be true for enabled buttons if disabled: :all" do
|
35
35
|
expect(@session).to have_button('med', disabled: :all)
|
36
36
|
end
|
37
|
+
|
38
|
+
it "can verify button type" do
|
39
|
+
expect(@session).to have_button('awe123', type: 'submit')
|
40
|
+
expect(@session).not_to have_button('awe123', type: 'reset')
|
41
|
+
end
|
37
42
|
end
|
38
43
|
|
39
44
|
Capybara::SpecHelper.spec '#has_no_button?' do
|