capybara-webkit 1.12.0 → 1.13.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 +3 -3
- data/Appraisals +3 -2
- data/Gemfile.lock +26 -18
- data/NEWS.md +9 -0
- data/README.md +4 -1
- data/capybara-webkit.gemspec +1 -1
- data/gemfiles/{2.11.gemfile → 2.12.gemfile} +1 -1
- data/gemfiles/2.7.gemfile +1 -0
- data/lib/capybara/webkit/browser.rb +25 -1
- data/lib/capybara/webkit/configuration.rb +4 -1
- data/lib/capybara/webkit/driver.rb +4 -0
- data/lib/capybara/webkit/errors.rb +9 -0
- data/lib/capybara/webkit/matchers.rb +5 -3
- data/lib/capybara/webkit/node.rb +1 -1
- data/lib/capybara/webkit/version.rb +1 -1
- data/spec/browser_spec.rb +22 -8
- data/spec/capybara_webkit_builder_spec.rb +4 -4
- data/spec/connection_spec.rb +3 -4
- data/spec/cookie_jar_spec.rb +10 -10
- data/spec/driver_rendering_spec.rb +14 -14
- data/spec/driver_resize_window_spec.rb +8 -8
- data/spec/driver_spec.rb +388 -349
- data/spec/errors_spec.rb +1 -1
- data/spec/integration/session_spec.rb +31 -31
- data/spec/selenium_compatibility_spec.rb +1 -1
- data/spec/server_spec.rb +11 -11
- data/spec/spec_helper.rb +11 -4
- data/spec/support/app_runner.rb +1 -0
- data/spec/support/matchers/include_response.rb +2 -2
- metadata +6 -6
data/spec/errors_spec.rb
CHANGED
@@ -50,7 +50,7 @@ describe Capybara::Session do
|
|
50
50
|
it "waits for a request to load" do
|
51
51
|
subject.visit("/")
|
52
52
|
subject.find_button("Submit").click
|
53
|
-
subject.
|
53
|
+
expect(subject).to have_content("Goodbye");
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -76,12 +76,12 @@ describe Capybara::Session do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it "inspects nodes" do
|
79
|
-
subject.all(:xpath, "//strong").first.inspect.
|
79
|
+
expect(subject.all(:xpath, "//strong").first.inspect).to include("strong")
|
80
80
|
end
|
81
81
|
|
82
82
|
it "can read utf8 string" do
|
83
83
|
utf8str = subject.all(:xpath, "//span").first.text
|
84
|
-
utf8str.
|
84
|
+
expect(utf8str).to eq('UTF8文字列')
|
85
85
|
end
|
86
86
|
|
87
87
|
it "can click utf8 string" do
|
@@ -91,7 +91,7 @@ describe Capybara::Session do
|
|
91
91
|
it "raises an ElementNotFound error when the selector scope is no longer valid" do
|
92
92
|
subject.within('//body') do
|
93
93
|
subject.click_link 'Link'
|
94
|
-
|
94
|
+
expect { subject.find('//strong') }.to raise_error(Capybara::ElementNotFound)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -119,26 +119,26 @@ describe Capybara::Session do
|
|
119
119
|
|
120
120
|
it "should get status code" do
|
121
121
|
subject.visit '/'
|
122
|
-
subject.status_code.
|
122
|
+
expect(subject.status_code).to eq 200
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should reset status code" do
|
126
126
|
subject.visit '/'
|
127
|
-
subject.status_code.
|
127
|
+
expect(subject.status_code).to eq 200
|
128
128
|
subject.reset!
|
129
|
-
subject.status_code.
|
129
|
+
expect(subject.status_code).to eq 0
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should get response headers" do
|
133
133
|
subject.visit '/'
|
134
|
-
subject.response_headers['X-Capybara'].
|
134
|
+
expect(subject.response_headers['X-Capybara']).to eq 'WebKit'
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should reset response headers" do
|
138
138
|
subject.visit '/'
|
139
|
-
subject.response_headers['X-Capybara'].
|
139
|
+
expect(subject.response_headers['X-Capybara']).to eq 'WebKit'
|
140
140
|
subject.reset!
|
141
|
-
subject.response_headers['X-Capybara'].
|
141
|
+
expect(subject.response_headers['X-Capybara']).to eq nil
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
@@ -188,7 +188,7 @@ describe Capybara::Session do
|
|
188
188
|
subject.visit("/")
|
189
189
|
subject.click_link('Click Me!')
|
190
190
|
Capybara.using_wait_time(5) do
|
191
|
-
subject.
|
191
|
+
expect(subject).to have_content("finished")
|
192
192
|
end
|
193
193
|
end
|
194
194
|
end
|
@@ -235,7 +235,7 @@ describe Capybara::Session do
|
|
235
235
|
subject.fill_in('password', with: 'temp4now')
|
236
236
|
subject.click_button('Submit')
|
237
237
|
subject.visit('/other')
|
238
|
-
subject.
|
238
|
+
expect(subject).to have_content('admin')
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
@@ -299,7 +299,7 @@ describe Capybara::Session do
|
|
299
299
|
subject.within_frame 'a_frame' do
|
300
300
|
subject.within_frame 'b_frame' do
|
301
301
|
subject.click_button 'B Button'
|
302
|
-
subject.
|
302
|
+
expect(subject).to have_content('Page C')
|
303
303
|
end
|
304
304
|
end
|
305
305
|
end
|
@@ -319,9 +319,9 @@ describe Capybara::Session do
|
|
319
319
|
|
320
320
|
subject.within_frame('a_frame') do
|
321
321
|
subject.within_frame('b_frame') do
|
322
|
-
|
322
|
+
expect {
|
323
323
|
subject.click_button 'B Button'
|
324
|
-
}.
|
324
|
+
}.to raise_error(Capybara::Webkit::ClickFailed)
|
325
325
|
end
|
326
326
|
end
|
327
327
|
end
|
@@ -379,29 +379,29 @@ describe Capybara::Session do
|
|
379
379
|
it 'clicks in the center of an element' do
|
380
380
|
subject.visit('/')
|
381
381
|
subject.find(:css, '#one').click
|
382
|
-
subject.find(:css, '#one')['data-click-x'].
|
383
|
-
subject.find(:css, '#one')['data-click-y'].
|
382
|
+
expect(subject.find(:css, '#one')['data-click-x']).to eq '199'
|
383
|
+
expect(subject.find(:css, '#one')['data-click-y']).to eq '199'
|
384
384
|
end
|
385
385
|
|
386
386
|
it 'clicks in the center of the viewable area of an element' do
|
387
387
|
subject.visit('/')
|
388
388
|
subject.driver.resize_window(200, 200)
|
389
389
|
subject.find(:css, '#one').click
|
390
|
-
subject.find(:css, '#one')['data-click-x'].
|
391
|
-
subject.find(:css, '#one')['data-click-y'].
|
390
|
+
expect(subject.find(:css, '#one')['data-click-x']).to eq '149'
|
391
|
+
expect(subject.find(:css, '#one')['data-click-y']).to eq '99'
|
392
392
|
end
|
393
393
|
|
394
394
|
it 'does not raise an error when an anchor contains empty nodes' do
|
395
395
|
subject.visit('/')
|
396
|
-
|
396
|
+
expect { subject.click_link('Some link') }.not_to raise_error
|
397
397
|
end
|
398
398
|
|
399
399
|
it 'scrolls an element into view when clicked' do
|
400
400
|
subject.visit('/')
|
401
401
|
subject.driver.resize_window(200, 200)
|
402
402
|
subject.find(:css, '#two').click
|
403
|
-
subject.find(:css, '#two')['data-click-x'].
|
404
|
-
subject.find(:css, '#two')['data-click-y'].
|
403
|
+
expect(subject.find(:css, '#two')['data-click-x']).not_to be_nil
|
404
|
+
expect(subject.find(:css, '#two')['data-click-y']).not_to be_nil
|
405
405
|
end
|
406
406
|
|
407
407
|
it 'raises an error if an element is obscured when clicked' do
|
@@ -417,11 +417,11 @@ describe Capybara::Session do
|
|
417
417
|
expect {
|
418
418
|
subject.find(:css, '#one').click
|
419
419
|
}.to raise_error(Capybara::Webkit::ClickFailed) { |exception|
|
420
|
-
exception.message.
|
420
|
+
expect(exception.message).to match %r{Failed.*\[@id='one'\].*overlapping.*\[@id='two'\].*at position}
|
421
421
|
screenshot_pattern = %r{A screenshot of the page at the time of the failure has been written to (.*)}
|
422
|
-
exception.message.
|
422
|
+
expect(exception.message).to match screenshot_pattern
|
423
423
|
file = exception.message.match(screenshot_pattern)[1]
|
424
|
-
File.exist?(file).
|
424
|
+
expect(File.exist?(file)).to be true
|
425
425
|
}
|
426
426
|
end
|
427
427
|
|
@@ -438,9 +438,9 @@ describe Capybara::Session do
|
|
438
438
|
document.body.appendChild(div);
|
439
439
|
JS
|
440
440
|
|
441
|
-
|
441
|
+
expect {
|
442
442
|
subject.check('bar')
|
443
|
-
}.
|
443
|
+
}.to raise_error(Capybara::Webkit::ClickFailed)
|
444
444
|
end
|
445
445
|
|
446
446
|
it 'raises an error if an element is not visible when clicked' do
|
@@ -449,7 +449,7 @@ describe Capybara::Session do
|
|
449
449
|
begin
|
450
450
|
subject.visit('/')
|
451
451
|
subject.execute_script "document.getElementById('foo').style.display = 'none'"
|
452
|
-
|
452
|
+
expect { subject.click_link "Click Me" }.to raise_error(
|
453
453
|
Capybara::Webkit::ClickFailed,
|
454
454
|
/\[@id='foo'\].*visible/
|
455
455
|
)
|
@@ -460,7 +460,7 @@ describe Capybara::Session do
|
|
460
460
|
|
461
461
|
it 'raises an error if an element is not in the viewport when clicked' do
|
462
462
|
subject.visit('/')
|
463
|
-
|
463
|
+
expect { subject.click_link "Click Me" }.to raise_error(Capybara::Webkit::ClickFailed)
|
464
464
|
end
|
465
465
|
|
466
466
|
context "with wait time of 1 second" do
|
@@ -479,7 +479,7 @@ describe Capybara::Session do
|
|
479
479
|
}, 400);
|
480
480
|
JS
|
481
481
|
|
482
|
-
|
482
|
+
expect { subject.click_link "Click Me" }.not_to raise_error
|
483
483
|
end
|
484
484
|
end
|
485
485
|
end
|
@@ -538,7 +538,7 @@ describe Capybara::Session do
|
|
538
538
|
session.attach_file 'File', file.path
|
539
539
|
session.click_on 'Go'
|
540
540
|
|
541
|
-
session.
|
541
|
+
expect(session).to have_text('Hello')
|
542
542
|
end
|
543
543
|
end
|
544
544
|
end
|
@@ -107,7 +107,7 @@ describe Capybara::Webkit, 'compatibility with selenium' do
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def compare_for_drivers(first, second, &block)
|
110
|
-
for_driver(first, &block).
|
110
|
+
expect(for_driver(first, &block)).to eq for_driver(second, &block)
|
111
111
|
end
|
112
112
|
|
113
113
|
def for_driver(name, &block)
|
data/spec/server_spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe Capybara::Webkit::Connection do
|
|
16
16
|
write_io.close
|
17
17
|
|
18
18
|
webkit_pid = read_io.read.to_i
|
19
|
-
webkit_pid.
|
19
|
+
expect(webkit_pid).to be > 1
|
20
20
|
read_io.close
|
21
21
|
Process.kill(9, fork_pid)
|
22
22
|
|
@@ -59,14 +59,14 @@ describe Capybara::Webkit::Connection do
|
|
59
59
|
socket.puts 1
|
60
60
|
socket.puts url.to_s.bytesize
|
61
61
|
socket.print url
|
62
|
-
socket.gets.
|
63
|
-
socket.gets.
|
62
|
+
expect(socket.gets).to eq "ok\n"
|
63
|
+
expect(socket.gets).to eq "0\n"
|
64
64
|
socket.puts "Body"
|
65
65
|
socket.puts 0
|
66
|
-
socket.gets.
|
66
|
+
expect(socket.gets).to eq "ok\n"
|
67
67
|
response_length = socket.gets.to_i
|
68
68
|
response = socket.read(response_length)
|
69
|
-
response.
|
69
|
+
expect(response).to include("Hey there")
|
70
70
|
end
|
71
71
|
|
72
72
|
it "forwards stderr to the given IO object" do
|
@@ -86,27 +86,27 @@ describe Capybara::Webkit::Connection do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it "does not forward stderr to nil" do
|
89
|
-
IO.
|
89
|
+
expect(IO).not_to receive(:copy_stream)
|
90
90
|
start_server(stderr: nil)
|
91
91
|
end
|
92
92
|
|
93
93
|
it "prints a deprecation warning if the stdout option is used" do
|
94
|
-
Capybara::Webkit::Server.
|
94
|
+
expect_any_instance_of(Capybara::Webkit::Server).to receive(:warn)
|
95
95
|
start_server(stdout: nil)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "does not forward stdout to nil if the stdout option is used" do
|
99
|
-
Capybara::Webkit::Server.
|
100
|
-
IO.
|
99
|
+
allow_any_instance_of(Capybara::Webkit::Server).to receive(:warn)
|
100
|
+
expect(IO).not_to receive(:copy_stream)
|
101
101
|
start_server(stdout: nil)
|
102
102
|
end
|
103
103
|
|
104
104
|
it "returns the server port" do
|
105
|
-
start_server.port.
|
105
|
+
expect(start_server.port).to be_between 0x400, 0xffff
|
106
106
|
end
|
107
107
|
|
108
108
|
it "chooses a new port number for a new connection" do
|
109
|
-
start_server.port.
|
109
|
+
expect(start_server.port).not_to eq start_server.port
|
110
110
|
end
|
111
111
|
|
112
112
|
before(:all) do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'rspec'
|
2
|
-
require 'rspec/autorun'
|
3
2
|
require 'rbconfig'
|
4
3
|
require 'capybara'
|
5
4
|
|
@@ -48,12 +47,20 @@ RSpec.configure do |c|
|
|
48
47
|
require 'capybara_webkit_builder'
|
49
48
|
c.filter_run_excluding :skip_on_qt4 => !(%x(#{CapybaraWebkitBuilder.qmake_bin} -v).match(/Using Qt version 4/)).nil?
|
50
49
|
|
51
|
-
# We can't support outerWidth and outerHeight without a visible window.
|
50
|
+
# We can't support outerWidth and outerHeight without a visible window. Only affects Capybara < 2.12.0
|
52
51
|
# We focus the next window instead of failing when closing windows.
|
52
|
+
# Accessing unattached nodes is allowed when reload is disabled - Legacy behavior
|
53
|
+
# Node#send_keys does not support modifiers and only supports a subset of special keys
|
53
54
|
c.filter_run_excluding :full_description => lambda { |description, metadata|
|
54
55
|
(description !~ /Capybara::Session webkit node #send_keys should send a string of keys to an element/) && (
|
55
|
-
|
56
|
-
|
56
|
+
description =~ /Capybara::Session webkit node #send_keys/ ||
|
57
|
+
description =~ /Capybara::Session webkit node #reload without automatic reload should not automatically reload/ ||
|
58
|
+
if Gem::Version.new(Capybara::VERSION) < Gem::Version.new("2.12.0")
|
59
|
+
description =~ /Capybara::Session webkit Capybara::Window\s*#(size|resize_to|maximize|close.*no_such_window_error|send_keys)/ ||
|
60
|
+
description =~ /Capybara::Session webkit node\s*#set should allow me to change the contents of a contenteditable elements child/
|
61
|
+
else
|
62
|
+
description =~ /Capybara::Session webkit Capybara::Window\s*#close.*no_such_window_error/
|
63
|
+
end
|
57
64
|
)
|
58
65
|
}
|
59
66
|
end
|
data/spec/support/app_runner.rb
CHANGED
@@ -14,11 +14,11 @@ RSpec::Matchers.define :include_response do |expected_response|
|
|
14
14
|
found_response
|
15
15
|
end
|
16
16
|
|
17
|
-
failure_message_for_should do |actual|
|
17
|
+
send(respond_to?(:failure_message) ? :failure_message : :failure_message_for_should) do |actual|
|
18
18
|
"expected #{response} to include #{expected_response}"
|
19
19
|
end
|
20
20
|
|
21
|
-
failure_message_for_should_not do |actual|
|
21
|
+
send(respond_to?(:failure_message_when_negated) ? :failure_message_when_negated : :failure_message_for_should_not) do |actual|
|
22
22
|
"expected #{response} to not include #{expected_response}"
|
23
23
|
end
|
24
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-webkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2017-
|
16
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: capybara
|
@@ -55,14 +55,14 @@ dependencies:
|
|
55
55
|
requirements:
|
56
56
|
- - "~>"
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: '
|
58
|
+
version: '3.5'
|
59
59
|
type: :development
|
60
60
|
prerelease: false
|
61
61
|
version_requirements: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
63
|
- - "~>"
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: '
|
65
|
+
version: '3.5'
|
66
66
|
- !ruby/object:Gem::Dependency
|
67
67
|
name: sinatra
|
68
68
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,7 +155,7 @@ files:
|
|
155
155
|
- bin/Info.plist
|
156
156
|
- capybara-webkit.gemspec
|
157
157
|
- extconf.rb
|
158
|
-
- gemfiles/2.
|
158
|
+
- gemfiles/2.12.gemfile
|
159
159
|
- gemfiles/2.7.gemfile
|
160
160
|
- gemfiles/master.gemfile
|
161
161
|
- lib/capybara-webkit.rb
|
@@ -385,7 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
385
385
|
requirements:
|
386
386
|
- Qt >= 4.8
|
387
387
|
rubyforge_project:
|
388
|
-
rubygems_version: 2.
|
388
|
+
rubygems_version: 2.6.8
|
389
389
|
signing_key:
|
390
390
|
specification_version: 4
|
391
391
|
summary: Headless Webkit driver for Capybara
|