capybara 2.10.2 → 2.11.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 +15 -0
- data/README.md +48 -29
- data/lib/capybara.rb +8 -9
- data/lib/capybara/node/actions.rb +39 -48
- data/lib/capybara/node/document.rb +4 -0
- data/lib/capybara/node/document_matchers.rb +13 -14
- data/lib/capybara/node/element.rb +21 -0
- data/lib/capybara/node/finders.rb +3 -3
- data/lib/capybara/node/matchers.rb +38 -31
- data/lib/capybara/node/simple.rb +3 -0
- data/lib/capybara/queries/selector_query.rb +4 -2
- data/lib/capybara/rack_test/node.rb +1 -1
- data/lib/capybara/result.rb +3 -1
- data/lib/capybara/rspec/matchers.rb +53 -95
- data/lib/capybara/selector.rb +7 -7
- data/lib/capybara/selector/selector.rb +10 -5
- data/lib/capybara/selenium/driver.rb +34 -7
- data/lib/capybara/selenium/node.rb +5 -1
- data/lib/capybara/session.rb +22 -27
- data/lib/capybara/session/matchers.rb +12 -14
- data/lib/capybara/spec/public/test.js +4 -0
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
- data/lib/capybara/spec/session/attach_file_spec.rb +1 -1
- data/lib/capybara/spec/session/check_spec.rb +8 -0
- data/lib/capybara/spec/session/choose_spec.rb +5 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +5 -0
- data/lib/capybara/spec/session/click_link_spec.rb +5 -0
- data/lib/capybara/spec/session/element/assert_match_selector.rb +5 -0
- data/lib/capybara/spec/session/element/match_css_spec.rb +6 -0
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +2 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +5 -0
- data/lib/capybara/spec/session/find_spec.rb +1 -1
- data/lib/capybara/spec/session/first_spec.rb +10 -0
- data/lib/capybara/spec/session/has_selector_spec.rb +11 -0
- data/lib/capybara/spec/session/node_spec.rb +3 -3
- data/lib/capybara/spec/session/text_spec.rb +3 -4
- data/lib/capybara/spec/views/with_js.erb +3 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +18 -2
- data/spec/basic_node_spec.rb +1 -1
- data/spec/capybara_spec.rb +4 -1
- data/spec/fixtures/selenium_driver_rspec_failure.rb +4 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +4 -1
- data/spec/result_spec.rb +28 -2
- data/spec/rspec/{matchers_spec.rb → shared_spec_matchers.rb} +4 -3
- data/spec/selector_spec.rb +1 -1
- data/spec/selenium_spec_chrome.rb +36 -5
- data/spec/selenium_spec_firefox.rb +67 -0
- data/spec/selenium_spec_marionette.rb +114 -0
- data/spec/shared_selenium_session.rb +6 -4
- metadata +13 -6
- data/spec/selenium_firefox_spec.rb +0 -44
@@ -0,0 +1,114 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
require "selenium-webdriver"
|
4
|
+
require 'shared_selenium_session'
|
5
|
+
require 'rspec/shared_spec_matchers'
|
6
|
+
|
7
|
+
Capybara.register_driver :selenium_marionette do |app|
|
8
|
+
Capybara::Selenium::Driver.new(
|
9
|
+
app,
|
10
|
+
browser: :firefox,
|
11
|
+
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox(marionette: true)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
Capybara.register_driver :selenium_marionette_clear_storage do |app|
|
16
|
+
Capybara::Selenium::Driver.new(
|
17
|
+
app,
|
18
|
+
browser: :firefox,
|
19
|
+
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox(marionette: true),
|
20
|
+
clear_local_storage: true,
|
21
|
+
clear_session_storage: true
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
module TestSessions
|
26
|
+
SeleniumMarionette = Capybara::Session.new(:selenium_marionette, TestApp)
|
27
|
+
end
|
28
|
+
|
29
|
+
skipped_tests = [
|
30
|
+
:response_headers,
|
31
|
+
:status_code,
|
32
|
+
:trigger
|
33
|
+
]
|
34
|
+
skipped_tests << :windows if ENV['TRAVIS'] && !ENV['WINDOW_TEST']
|
35
|
+
|
36
|
+
Capybara::SpecHelper.run_specs TestSessions::SeleniumMarionette, "selenium", capybara_skip: skipped_tests
|
37
|
+
|
38
|
+
RSpec.describe "Capybara::Session with firefox" do
|
39
|
+
include_examples "Capybara::Session", TestSessions::SeleniumMarionette, :selenium_marionette
|
40
|
+
include_examples Capybara::RSpecMatchers, TestSessions::SeleniumMarionette, :selenium_marionette
|
41
|
+
end
|
42
|
+
|
43
|
+
RSpec.describe Capybara::Selenium::Driver do
|
44
|
+
before do
|
45
|
+
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox)
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#quit' do
|
49
|
+
it "should reset browser when quit" do
|
50
|
+
expect(@driver.browser).to be
|
51
|
+
@driver.quit
|
52
|
+
#access instance variable directly so we don't create a new browser instance
|
53
|
+
expect(@driver.instance_variable_get(:@browser)).to be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with errors" do
|
57
|
+
before do
|
58
|
+
@original_browser = @driver.browser
|
59
|
+
end
|
60
|
+
after do
|
61
|
+
# Ensure browser is actually quit so we don't leave hanging processe
|
62
|
+
RSpec::Mocks.space.proxy_for(@original_browser).reset
|
63
|
+
@original_browser.quit
|
64
|
+
end
|
65
|
+
|
66
|
+
it "warns UnknownError returned during quit because the browser is probably already gone" do
|
67
|
+
expect_any_instance_of(Capybara::Selenium::Driver).to receive(:warn).with(/random message/)
|
68
|
+
allow(@driver.browser).to(
|
69
|
+
receive(:quit)
|
70
|
+
.and_raise(Selenium::WebDriver::Error::UnknownError, "random message")
|
71
|
+
)
|
72
|
+
|
73
|
+
expect { @driver.quit }.not_to raise_error
|
74
|
+
expect(@driver.instance_variable_get(:@browser)).to be_nil
|
75
|
+
end
|
76
|
+
|
77
|
+
it "ignores silenced UnknownError returned during quit because the browser is almost definitely already gone" do
|
78
|
+
expect_any_instance_of(Capybara::Selenium::Driver).not_to receive(:warn)
|
79
|
+
allow(@driver.browser).to(
|
80
|
+
receive(:quit)
|
81
|
+
.and_raise(Selenium::WebDriver::Error::UnknownError, "Error communicating with the remote browser")
|
82
|
+
)
|
83
|
+
|
84
|
+
expect { @driver.quit }.not_to raise_error
|
85
|
+
expect(@driver.instance_variable_get(:@browser)).to be_nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "storage" do
|
91
|
+
describe "#reset!" do
|
92
|
+
it "does not clear either storage by default" do
|
93
|
+
@session = TestSessions::SeleniumMarionette
|
94
|
+
@session.visit('/with_js')
|
95
|
+
@session.find(:css, '#set-storage').click
|
96
|
+
@session.reset!
|
97
|
+
@session.visit('/with_js')
|
98
|
+
expect(@session.driver.browser.local_storage.keys).not_to be_empty
|
99
|
+
expect(@session.driver.browser.session_storage.keys).not_to be_empty
|
100
|
+
end
|
101
|
+
|
102
|
+
it "clears storage when set" do
|
103
|
+
@session = Capybara::Session.new(:selenium_marionette_clear_storage, TestApp)
|
104
|
+
@session.visit('/with_js')
|
105
|
+
@session.find(:css, '#set-storage').click
|
106
|
+
@session.reset!
|
107
|
+
@session.visit('/with_js')
|
108
|
+
expect(@session.driver.browser.local_storage.keys).to be_empty
|
109
|
+
expect(@session.driver.browser.session_storage.keys).to be_empty
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
@@ -41,14 +41,16 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should have return code 1 when running selenium_driver_rspec_failure.rb" do
|
44
|
-
|
45
|
-
|
44
|
+
env = { 'SELENIUM_BROWSER' => @session.driver.options[:browser].to_s,
|
45
|
+
'LEGACY_FIREFOX' => (mode == :selenium_firefox ? 'TRUE' : nil) }
|
46
|
+
system(env, 'rspec spec/fixtures/selenium_driver_rspec_failure.rb', out: File::NULL, err: File::NULL)
|
46
47
|
expect($?.exitstatus).to eq(1)
|
47
48
|
end
|
48
49
|
|
49
50
|
it "should have return code 0 when running selenium_driver_rspec_success.rb" do
|
50
|
-
|
51
|
-
|
51
|
+
env = { 'SELENIUM_BROWSER' => @session.driver.options[:browser].to_s,
|
52
|
+
'LEGACY_FIREFOX' => (mode == :selenium_firefox ? 'TRUE' : nil) }
|
53
|
+
system(env, 'rspec spec/fixtures/selenium_driver_rspec_success.rb', out: File::NULL, err: File::NULL)
|
52
54
|
expect($?.exitstatus).to eq(0)
|
53
55
|
end
|
54
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Walpole
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain:
|
12
12
|
- gem-public_cert.pem
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -100,16 +100,22 @@ dependencies:
|
|
100
100
|
name: selenium-webdriver
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - "
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '2.0'
|
106
|
+
- - "<"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '4.0'
|
106
109
|
type: :development
|
107
110
|
prerelease: false
|
108
111
|
version_requirements: !ruby/object:Gem::Requirement
|
109
112
|
requirements:
|
110
|
-
- - "
|
113
|
+
- - ">="
|
111
114
|
- !ruby/object:Gem::Version
|
112
115
|
version: '2.0'
|
116
|
+
- - "<"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '4.0'
|
113
119
|
- !ruby/object:Gem::Dependency
|
114
120
|
name: sinatra
|
115
121
|
requirement: !ruby/object:Gem::Requirement
|
@@ -412,13 +418,14 @@ files:
|
|
412
418
|
- spec/rack_test_spec.rb
|
413
419
|
- spec/result_spec.rb
|
414
420
|
- spec/rspec/features_spec.rb
|
415
|
-
- spec/rspec/matchers_spec.rb
|
416
421
|
- spec/rspec/scenarios_spec.rb
|
422
|
+
- spec/rspec/shared_spec_matchers.rb
|
417
423
|
- spec/rspec/views_spec.rb
|
418
424
|
- spec/rspec_spec.rb
|
419
425
|
- spec/selector_spec.rb
|
420
|
-
- spec/selenium_firefox_spec.rb
|
421
426
|
- spec/selenium_spec_chrome.rb
|
427
|
+
- spec/selenium_spec_firefox.rb
|
428
|
+
- spec/selenium_spec_marionette.rb
|
422
429
|
- spec/server_spec.rb
|
423
430
|
- spec/shared_selenium_session.rb
|
424
431
|
- spec/spec_helper.rb
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'spec_helper'
|
3
|
-
require "selenium-webdriver"
|
4
|
-
require 'shared_selenium_session'
|
5
|
-
|
6
|
-
Capybara.register_driver :selenium_focus do |app|
|
7
|
-
# profile = Selenium::WebDriver::Firefox::Profile.new
|
8
|
-
# profile["focusmanager.testmode"] = true
|
9
|
-
# Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
|
10
|
-
Capybara::Selenium::Driver.new(app, browser: :firefox)
|
11
|
-
end
|
12
|
-
|
13
|
-
module TestSessions
|
14
|
-
Selenium = Capybara::Session.new(:selenium_focus, TestApp)
|
15
|
-
end
|
16
|
-
|
17
|
-
skipped_tests = [
|
18
|
-
:response_headers,
|
19
|
-
:status_code,
|
20
|
-
:trigger
|
21
|
-
]
|
22
|
-
skipped_tests << :windows if ENV['TRAVIS'] && !ENV['WINDOW_TEST']
|
23
|
-
|
24
|
-
Capybara::SpecHelper.run_specs TestSessions::Selenium, "selenium", capybara_skip: skipped_tests
|
25
|
-
|
26
|
-
RSpec.describe "Capybara::Session with firefox" do
|
27
|
-
include_examples "Capybara::Session", TestSessions::Selenium, :selenium_focus
|
28
|
-
end
|
29
|
-
|
30
|
-
RSpec.describe Capybara::Selenium::Driver do
|
31
|
-
before do
|
32
|
-
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox)
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#quit' do
|
36
|
-
it "should reset browser when quit" do
|
37
|
-
expect(@driver.browser).to be
|
38
|
-
@driver.quit
|
39
|
-
#access instance variable directly so we don't create a new browser instance
|
40
|
-
expect(@driver.instance_variable_get(:@browser)).to be_nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|