capybara 2.10.2 → 2.11.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 +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
@@ -52,6 +52,8 @@ Capybara::SpecHelper.spec '#match_selector?' do
|
|
52
52
|
it 'should accept a custom filter block' do
|
53
53
|
@session.visit('/form')
|
54
54
|
cbox = @session.find(:css, '#form_pets_dog')
|
55
|
+
expect(cbox).to match_selector(:checkbox){ |node| node[:id] == "form_pets_dog"}
|
56
|
+
expect(cbox).not_to match_selector(:checkbox){ |node| node[:id] != "form_pets_dog"}
|
55
57
|
expect(cbox.matches_selector?(:checkbox){ |node| node[:id] == "form_pets_dog"}).to be true
|
56
58
|
expect(cbox.matches_selector?(:checkbox){ |node| node[:id] != "form_pets_dog"}).to be false
|
57
59
|
end
|
@@ -181,4 +181,9 @@ Capybara::SpecHelper.spec "#fill_in" do
|
|
181
181
|
end.to raise_error(Capybara::ElementNotFound)
|
182
182
|
end
|
183
183
|
end
|
184
|
+
|
185
|
+
it "should return the element filled in" do
|
186
|
+
el = @session.find(:fillable_field, 'form_first_name')
|
187
|
+
expect(@session.fill_in('form_first_name', with: 'Harry')).to eq el
|
188
|
+
end
|
184
189
|
end
|
@@ -320,7 +320,7 @@ Capybara::SpecHelper.spec '#find' do
|
|
320
320
|
end
|
321
321
|
it "raises an error when there is a single inexact matches" do
|
322
322
|
expect do
|
323
|
-
|
323
|
+
@session.find(:xpath, XPath.descendant[XPath.attr(:class).is("almost_singular but")], match: :smart, exact: true)
|
324
324
|
end.to raise_error(Capybara::ElementNotFound)
|
325
325
|
end
|
326
326
|
it "raises an error if there is no match" do
|
@@ -19,6 +19,11 @@ Capybara::SpecHelper.spec '#first' do
|
|
19
19
|
expect(@session.first(@xpath).value).to eq('John')
|
20
20
|
end
|
21
21
|
|
22
|
+
it "should warn when unused parameters are passed" do
|
23
|
+
expect_any_instance_of(Kernel).to receive(:warn).with(/Unused parameters passed.*unused text/)
|
24
|
+
@session.first(:css, '.header h2', 'unused text')
|
25
|
+
end
|
26
|
+
|
22
27
|
context "with css selectors" do
|
23
28
|
it "should find the first element using the given selector" do
|
24
29
|
expect(@session.first(:css, 'h1').text).to eq('This is a test')
|
@@ -48,21 +53,26 @@ Capybara::SpecHelper.spec '#first' do
|
|
48
53
|
|
49
54
|
it "should find nodes regardless of whether they are invisible when false" do
|
50
55
|
expect(@session.first(:css, "a#invisible", visible: false)).not_to be_nil
|
56
|
+
expect(@session.first(:css, "a#invisible", visible: false, text: 'hidden link')).not_to be_nil
|
51
57
|
expect(@session.first(:css, "a#visible", visible: false)).not_to be_nil
|
52
58
|
end
|
53
59
|
|
54
60
|
it "should find nodes regardless of whether they are invisible when :all" do
|
55
61
|
expect(@session.first(:css, "a#invisible", visible: :all)).not_to be_nil
|
62
|
+
expect(@session.first(:css, "a#invisible", visible: :all, text: 'hidden link')).not_to be_nil
|
56
63
|
expect(@session.first(:css, "a#visible", visible: :all)).not_to be_nil
|
57
64
|
end
|
58
65
|
|
59
66
|
it "should find only hidden nodes when :hidden" do
|
60
67
|
expect(@session.first(:css, "a#invisible", visible: :hidden)).not_to be_nil
|
68
|
+
expect(@session.first(:css, "a#invisible", visible: :hidden, text: 'hidden link')).not_to be_nil
|
69
|
+
expect(@session.first(:css, "a#invisible", visible: :hidden, text: 'not hidden link')).to be_nil
|
61
70
|
expect(@session.first(:css, "a#visible", visible: :hidden)).to be_nil
|
62
71
|
end
|
63
72
|
|
64
73
|
it "should find only visible nodes when :visible" do
|
65
74
|
expect(@session.first(:css, "a#invisible", visible: :visible)).to be_nil
|
75
|
+
expect(@session.first(:css, "a#invisible", visible: :visible, text: 'hidden link')).to be_nil
|
66
76
|
expect(@session.first(:css, "a#visible", visible: :visible)).not_to be_nil
|
67
77
|
end
|
68
78
|
|
@@ -29,6 +29,10 @@ Capybara::SpecHelper.spec '#has_selector?' do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
it "should accept a filter block" do
|
33
|
+
expect(@session).to have_selector(:css, "a", count: 1) { |el| el[:id] == "foo" }
|
34
|
+
end
|
35
|
+
|
32
36
|
context "with count" do
|
33
37
|
it "should be true if the content is on the page the given number of times" do
|
34
38
|
expect(@session).to have_selector("//p", count: 3)
|
@@ -105,6 +109,13 @@ Capybara::SpecHelper.spec '#has_no_selector?' do
|
|
105
109
|
end
|
106
110
|
end
|
107
111
|
|
112
|
+
it "should accept a filter block" do
|
113
|
+
if !defined?(::RSpec::Expectations::Version) || (Gem::Version.new(RSpec::Expectations::Version::STRING) < Gem::Version.new('3.0'))
|
114
|
+
skip "RSpec < 3 doesn't pass the block along to the matcher for the Builtin::Has matcher"
|
115
|
+
end
|
116
|
+
expect(@session).to have_no_selector(:css, "a#foo") { |el| el[:id] != "foo" }
|
117
|
+
end
|
118
|
+
|
108
119
|
context "with count" do
|
109
120
|
it "should be false if the content is on the page the given number of times" do
|
110
121
|
expect(@session).not_to have_no_selector("//p", count: 3)
|
@@ -425,18 +425,18 @@ Capybara::SpecHelper.spec "node" do
|
|
425
425
|
@session.find(:css, 'span')
|
426
426
|
end.to raise_error(TestApp::TestAppError) do |e|
|
427
427
|
expect(e.cause).to be_a Capybara::CapybaraError
|
428
|
-
expect(e.cause.message).to match
|
428
|
+
expect(e.cause.message).to match(/Your application server raised an error/)
|
429
429
|
end
|
430
430
|
end
|
431
431
|
|
432
|
-
it "sets an explanatory exception as the cause of server exceptions with errors with initializers", requires: [:server, :js]
|
432
|
+
it "sets an explanatory exception as the cause of server exceptions with errors with initializers", requires: [:server, :js] do
|
433
433
|
skip "This version of ruby doesn't support exception causes" unless Exception.instance_methods.include? :cause
|
434
434
|
quietly { @session.visit("/other_error") }
|
435
435
|
expect do
|
436
436
|
@session.find(:css, 'span')
|
437
437
|
end.to raise_error(TestApp::TestAppOtherError) do |e|
|
438
438
|
expect(e.cause).to be_a Capybara::CapybaraError
|
439
|
-
expect(e.cause.message).to match
|
439
|
+
expect(e.cause.message).to match(/Your application server raised an error/)
|
440
440
|
end
|
441
441
|
end
|
442
442
|
end
|
@@ -35,7 +35,7 @@ Capybara::SpecHelper.spec '#text' do
|
|
35
35
|
Capybara.ignore_hidden_elements = false
|
36
36
|
expect(@session.find(:id, "hidden-text").text).to eq('Some of this text is')
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it "ignores invisible text if ancestor is invisible" do
|
40
40
|
@session.visit('/with_html')
|
41
41
|
expect(@session.find(:id, "hidden_via_ancestor", visible: false).text).to eq('')
|
@@ -52,8 +52,7 @@ Capybara::SpecHelper.spec '#text' do
|
|
52
52
|
|
53
53
|
it "should strip whitespace" do
|
54
54
|
@session.visit('/with_html')
|
55
|
-
|
56
|
-
expect(@session.find(:css, '#second').text).to match
|
57
|
-
/\ADuis aute .* text with whitespace .* est laborum\.\z/
|
55
|
+
@session.find(:css, '#second')
|
56
|
+
expect(@session.find(:css, '#second').text).to match(/\ADuis aute .* text with whitespace .* est laborum\.\z/)
|
58
57
|
end
|
59
58
|
end
|
data/lib/capybara/version.rb
CHANGED
data/lib/capybara/window.rb
CHANGED
@@ -85,7 +85,7 @@ module Capybara
|
|
85
85
|
# @param height [String] the new window height in pixels
|
86
86
|
#
|
87
87
|
def resize_to(width, height)
|
88
|
-
@driver.resize_window_to(handle, width, height)
|
88
|
+
wait_for_stable_size { @driver.resize_window_to(handle, width, height) }
|
89
89
|
end
|
90
90
|
|
91
91
|
##
|
@@ -97,7 +97,7 @@ module Capybara
|
|
97
97
|
# @macro about_current
|
98
98
|
#
|
99
99
|
def maximize
|
100
|
-
@driver.maximize_window(handle)
|
100
|
+
wait_for_stable_size { @driver.maximize_window(handle) }
|
101
101
|
end
|
102
102
|
|
103
103
|
def eql?(other)
|
@@ -115,6 +115,22 @@ module Capybara
|
|
115
115
|
|
116
116
|
private
|
117
117
|
|
118
|
+
def wait_for_stable_size(seconds=Capybara.default_max_wait_time)
|
119
|
+
res = yield if block_given?
|
120
|
+
prev_size = size
|
121
|
+
start_time = Capybara::Helpers.monotonic_time
|
122
|
+
begin
|
123
|
+
sleep 0.05
|
124
|
+
cur_size = size
|
125
|
+
return res if cur_size == prev_size
|
126
|
+
prev_size = cur_size
|
127
|
+
end while (Capybara::Helpers.monotonic_time - start_time) < seconds
|
128
|
+
#TODO raise error in 3.0
|
129
|
+
#raise Capybara::WindowError, "Window size not stable."
|
130
|
+
warn "Window size not stable in #{seconds} seconds. This will raise an exception in a future version of Capybara"
|
131
|
+
return res
|
132
|
+
end
|
133
|
+
|
118
134
|
def raise_unless_current(what)
|
119
135
|
unless current?
|
120
136
|
raise Capybara::WindowError, "#{what} not current window is not possible."
|
data/spec/basic_node_spec.rb
CHANGED
@@ -52,7 +52,7 @@ RSpec.describe Capybara do
|
|
52
52
|
|
53
53
|
it "allows using custom matchers" do
|
54
54
|
Capybara.add_selector :lifeform do
|
55
|
-
xpath { |name| "
|
55
|
+
xpath { |name| ".//option[contains(.,'#{name}')]" }
|
56
56
|
end
|
57
57
|
expect(string).to have_selector(:id, "page")
|
58
58
|
expect(string).not_to have_selector(:id, 'does-not-exist')
|
data/spec/capybara_spec.rb
CHANGED
@@ -46,11 +46,14 @@ RSpec.describe Capybara do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should add a new server" do
|
49
|
+
skip "JRuby fails this because of path issues to geckodriver I think. Its tested in other runs - not worth figuring out at this time" if RUBY_PLATFORM == 'java'
|
50
|
+
|
51
|
+
require 'rack/handler/webrick'
|
49
52
|
Capybara.register_server :blob do |app, port, host|
|
50
53
|
Rack::Handler::WEBrick.run(app, Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log::new(nil, 0))
|
51
54
|
end
|
52
55
|
Capybara.server = :blob
|
53
|
-
session = Capybara::Session.new(:selenium, TestApp.
|
56
|
+
session = Capybara::Session.new(:selenium, TestApp.new)
|
54
57
|
session.visit('/')
|
55
58
|
expect(session.body).to include("Hello world!")
|
56
59
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'spec_helper'
|
3
|
+
require 'selenium-webdriver'
|
3
4
|
|
4
5
|
RSpec.describe Capybara::Selenium::Driver do
|
5
6
|
it "should exit with a non-zero exit status" do
|
6
|
-
|
7
|
+
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
|
8
|
+
options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false) if ENV['LEGACY_FIREFOX']
|
9
|
+
browser = Capybara::Selenium::Driver.new(TestApp, options).browser
|
7
10
|
expect(true).to eq(false)
|
8
11
|
end
|
9
12
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'spec_helper'
|
3
|
+
require 'selenium-webdriver'
|
3
4
|
|
4
5
|
RSpec.describe Capybara::Selenium::Driver do
|
5
6
|
it "should exit with a zero exit status" do
|
6
|
-
|
7
|
+
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
|
8
|
+
options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false) if ENV['LEGACY_FIREFOX']
|
9
|
+
browser = Capybara::Selenium::Driver.new(TestApp, options ).browser
|
7
10
|
expect(true).to eq(true)
|
8
11
|
end
|
9
12
|
end
|
data/spec/result_spec.rb
CHANGED
@@ -66,8 +66,8 @@ RSpec.describe Capybara::Result do
|
|
66
66
|
|
67
67
|
it 'supports all modes of []' do
|
68
68
|
expect(result[1].text).to eq 'Beta'
|
69
|
-
expect(result[0,2].map
|
70
|
-
expect(result[1..3].map
|
69
|
+
expect(result[0,2].map(&:text)).to eq ['Alpha', 'Beta']
|
70
|
+
expect(result[1..3].map(&:text)).to eq ['Beta', 'Gamma', 'Delta']
|
71
71
|
expect(result[-1].text).to eq 'Delta'
|
72
72
|
end
|
73
73
|
|
@@ -92,4 +92,30 @@ RSpec.describe Capybara::Result do
|
|
92
92
|
result.to_a
|
93
93
|
expect(result.instance_variable_get('@result_cache').size).to eq 4
|
94
94
|
end
|
95
|
+
|
96
|
+
context '#each' do
|
97
|
+
it 'lazily evaluates' do
|
98
|
+
skip 'JRuby has an issue with lazy enumerator next evaluation' if RUBY_PLATFORM == 'java'
|
99
|
+
results=[]
|
100
|
+
result.each do |el|
|
101
|
+
results << el
|
102
|
+
expect(result.instance_variable_get('@result_cache').size).to eq results.size
|
103
|
+
end
|
104
|
+
|
105
|
+
expect(results.size).to eq 4
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'without a block' do
|
109
|
+
it 'returns an iterator' do
|
110
|
+
expect(result.each).to be_a(Enumerator)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'lazily evaluates' do
|
114
|
+
skip 'JRuby has an issue with lazy enumerator next evaluation' if RUBY_PLATFORM == 'java'
|
115
|
+
result.each.with_index do |el, idx|
|
116
|
+
expect(result.instance_variable_get('@result_cache').size).to eq(idx+1) # 0 indexing
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
95
121
|
end
|
@@ -3,7 +3,8 @@ require 'spec_helper'
|
|
3
3
|
require 'capybara/dsl'
|
4
4
|
require 'capybara/rspec/matchers'
|
5
5
|
|
6
|
-
RSpec.
|
6
|
+
RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
|
7
|
+
|
7
8
|
include Capybara::DSL
|
8
9
|
include Capybara::RSpecMatchers
|
9
10
|
|
@@ -541,7 +542,7 @@ RSpec.describe Capybara::RSpecMatchers do
|
|
541
542
|
|
542
543
|
context 'with wait' do
|
543
544
|
before(:each) do
|
544
|
-
@session =
|
545
|
+
@session = session
|
545
546
|
@session.visit('/with_js')
|
546
547
|
end
|
547
548
|
|
@@ -586,7 +587,7 @@ RSpec.describe Capybara::RSpecMatchers do
|
|
586
587
|
|
587
588
|
context 'with wait' do
|
588
589
|
before(:each) do
|
589
|
-
@session =
|
590
|
+
@session = session
|
590
591
|
@session.visit('/with_js')
|
591
592
|
end
|
592
593
|
|
data/spec/selector_spec.rb
CHANGED
@@ -102,7 +102,7 @@ RSpec.describe Capybara do
|
|
102
102
|
table: ".//table"
|
103
103
|
}
|
104
104
|
selectors.each do |selector, xpath|
|
105
|
-
results = string.all(selector,nil).to_a.map
|
105
|
+
results = string.all(selector,nil).to_a.map(&:native)
|
106
106
|
expect(results.size).to be > 0
|
107
107
|
expect(results).to eq string.all(:xpath, xpath).to_a.map(&:native)
|
108
108
|
end
|
@@ -8,16 +8,47 @@ Capybara.register_driver :selenium_chrome do |app|
|
|
8
8
|
Capybara::Selenium::Driver.new(app, :browser => :chrome, :args => args)
|
9
9
|
end
|
10
10
|
|
11
|
+
Capybara.register_driver :selenium_chrome_clear_storage do |app|
|
12
|
+
args = ENV['TRAVIS'] ? ['no-sandbox' ] : []
|
13
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome,
|
14
|
+
:args => args,
|
15
|
+
clear_local_storage: true,
|
16
|
+
clear_session_storage: true)
|
17
|
+
end
|
18
|
+
|
11
19
|
module TestSessions
|
12
20
|
Chrome = Capybara::Session.new(:selenium_chrome, TestApp)
|
13
21
|
end
|
14
22
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
] unless ENV['TRAVIS'] && (RUBY_PLATFORM == 'java')
|
23
|
+
skipped_tests = [:response_headers, :status_code, :trigger]
|
24
|
+
skipped_tests << :windows if ENV['TRAVIS'] && !ENV['WINDOW_TEST']
|
25
|
+
|
26
|
+
Capybara::SpecHelper.run_specs TestSessions::Chrome, "selenium_chrome", capybara_skip: skipped_tests
|
20
27
|
|
21
28
|
RSpec.describe "Capybara::Session with chrome" do
|
22
29
|
include_examples "Capybara::Session", TestSessions::Chrome, :selenium_chrome
|
30
|
+
|
31
|
+
context "storage" do
|
32
|
+
describe "#reset!" do
|
33
|
+
it "does not clear either storage by default" do
|
34
|
+
@session = TestSessions::Chrome
|
35
|
+
@session.visit('/with_js')
|
36
|
+
@session.find(:css, '#set-storage').click
|
37
|
+
@session.reset!
|
38
|
+
@session.visit('/with_js')
|
39
|
+
expect(@session.driver.browser.local_storage.keys).not_to be_empty
|
40
|
+
expect(@session.driver.browser.session_storage.keys).not_to be_empty
|
41
|
+
end
|
42
|
+
|
43
|
+
it "clears storage when set" do
|
44
|
+
@session = Capybara::Session.new(:selenium_chrome_clear_storage, TestApp)
|
45
|
+
@session.visit('/with_js')
|
46
|
+
@session.find(:css, '#set-storage').click
|
47
|
+
@session.reset!
|
48
|
+
@session.visit('/with_js')
|
49
|
+
expect(@session.driver.browser.local_storage.keys).to be_empty
|
50
|
+
expect(@session.driver.browser.session_storage.keys).to be_empty
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
23
54
|
end
|
@@ -0,0 +1,67 @@
|
|
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_firefox do |app|
|
8
|
+
Capybara::Selenium::Driver.new(
|
9
|
+
app,
|
10
|
+
browser: :firefox,
|
11
|
+
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
Capybara.register_driver :selenium_firefox_cant_clear_storage do |app|
|
16
|
+
Capybara::Selenium::Driver.new(
|
17
|
+
app,
|
18
|
+
browser: :firefox,
|
19
|
+
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false),
|
20
|
+
clear_local_storage: true,
|
21
|
+
clear_session_storage: true
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
module TestSessions
|
26
|
+
Selenium = Capybara::Session.new(:selenium_firefox, 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::Selenium, "selenium", capybara_skip: skipped_tests
|
37
|
+
|
38
|
+
RSpec.describe "Capybara::Session with legacy firefox" do
|
39
|
+
include_examples "Capybara::Session", TestSessions::Selenium, :selenium_firefox
|
40
|
+
include_examples Capybara::RSpecMatchers, TestSessions::Selenium, :selenium_firefox
|
41
|
+
|
42
|
+
context "storage" do
|
43
|
+
it "warns storage clearing isn't available" do
|
44
|
+
@session = Capybara::Session.new(:selenium_firefox_cant_clear_storage, TestApp)
|
45
|
+
expect_any_instance_of(Kernel).to receive(:warn).with('sessionStorage clear requested but is not available for this driver')
|
46
|
+
expect_any_instance_of(Kernel).to receive(:warn).with('localStorage clear requested but is not available for this driver')
|
47
|
+
@session.visit('/')
|
48
|
+
@session.reset!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
RSpec.describe Capybara::Selenium::Driver do
|
54
|
+
before do
|
55
|
+
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox, desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false))
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#quit' do
|
59
|
+
it "should reset browser when quit" do
|
60
|
+
expect(@driver.browser).to be
|
61
|
+
@driver.quit
|
62
|
+
#access instance variable directly so we don't create a new browser instance
|
63
|
+
expect(@driver.instance_variable_get(:@browser)).to be_nil
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|