capybara 3.14.0 → 3.15.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +13 -0
  3. data/README.md +2 -1
  4. data/lib/capybara/node/actions.rb +37 -6
  5. data/lib/capybara/node/matchers.rb +10 -2
  6. data/lib/capybara/selector.rb +117 -1
  7. data/lib/capybara/selector/selector.rb +7 -0
  8. data/lib/capybara/selector/xpath_extensions.rb +9 -0
  9. data/lib/capybara/selenium/driver.rb +13 -2
  10. data/lib/capybara/selenium/driver_specializations/safari_driver.rb +15 -0
  11. data/lib/capybara/selenium/extensions/find.rb +2 -1
  12. data/lib/capybara/selenium/node.rb +1 -1
  13. data/lib/capybara/selenium/nodes/firefox_node.rb +1 -1
  14. data/lib/capybara/selenium/nodes/safari_node.rb +145 -0
  15. data/lib/capybara/spec/session/attach_file_spec.rb +46 -27
  16. data/lib/capybara/spec/session/click_button_spec.rb +65 -60
  17. data/lib/capybara/spec/session/element/matches_selector_spec.rb +40 -39
  18. data/lib/capybara/spec/session/fill_in_spec.rb +3 -3
  19. data/lib/capybara/spec/session/find_spec.rb +5 -0
  20. data/lib/capybara/spec/session/has_table_spec.rb +120 -0
  21. data/lib/capybara/spec/session/node_spec.rb +3 -3
  22. data/lib/capybara/spec/session/reset_session_spec.rb +8 -7
  23. data/lib/capybara/spec/session/window/become_closed_spec.rb +20 -17
  24. data/lib/capybara/spec/session/window/window_spec.rb +44 -48
  25. data/lib/capybara/spec/views/form.erb +5 -0
  26. data/lib/capybara/spec/views/tables.erb +67 -0
  27. data/lib/capybara/spec/views/with_html.erb +2 -2
  28. data/lib/capybara/spec/views/with_js.erb +1 -0
  29. data/lib/capybara/version.rb +1 -1
  30. data/spec/capybara_spec.rb +4 -4
  31. data/spec/css_builder_spec.rb +2 -0
  32. data/spec/dsl_spec.rb +13 -17
  33. data/spec/rack_test_spec.rb +77 -85
  34. data/spec/rspec/features_spec.rb +2 -0
  35. data/spec/rspec/shared_spec_matchers.rb +34 -35
  36. data/spec/rspec_spec.rb +11 -13
  37. data/spec/selector_spec.rb +31 -0
  38. data/spec/selenium_spec_chrome.rb +25 -25
  39. data/spec/selenium_spec_firefox.rb +62 -35
  40. data/spec/selenium_spec_firefox_remote.rb +2 -0
  41. data/spec/selenium_spec_safari.rb +148 -0
  42. data/spec/server_spec.rb +40 -44
  43. data/spec/shared_selenium_session.rb +27 -21
  44. data/spec/spec_helper.rb +4 -0
  45. data/spec/xpath_builder_spec.rb +2 -0
  46. metadata +7 -3
@@ -3,6 +3,7 @@
3
3
  require 'spec_helper'
4
4
  require 'capybara/rspec'
5
5
 
6
+ # rubocop:disable RSpec/InstanceVariable
6
7
  RSpec.configuration.before(:each, file_path: './spec/rspec/features_spec.rb') do
7
8
  @in_filtered_hook = true
8
9
  end
@@ -53,6 +54,7 @@ feature "Capybara's feature DSL" do
53
54
  end
54
55
  end
55
56
  end
57
+ # rubocop:enable RSpec/InstanceVariable
56
58
 
57
59
  feature 'given and given! aliases to let and let!' do
58
60
  given(:value) { :available }
@@ -555,21 +555,20 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
555
555
 
556
556
  context 'with wait' do
557
557
  before do
558
- @session = session
559
- @session.visit('/with_js')
558
+ session.visit('/with_js')
560
559
  end
561
560
 
562
561
  it 'waits if wait time is more than timeout' do
563
- @session.click_link('Change title')
562
+ session.click_link('Change title')
564
563
  using_wait_time 0 do
565
- expect(@session).to have_title('changed title', wait: 2)
564
+ expect(session).to have_title('changed title', wait: 2)
566
565
  end
567
566
  end
568
567
 
569
568
  it "doesn't wait if wait time is less than timeout" do
570
- @session.click_link('Change title')
569
+ session.click_link('Change title')
571
570
  using_wait_time 3 do
572
- expect(@session).not_to have_title('changed title', wait: 0)
571
+ expect(session).not_to have_title('changed title', wait: 0)
573
572
  end
574
573
  end
575
574
  end
@@ -600,21 +599,20 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
600
599
 
601
600
  context 'with wait' do
602
601
  before do
603
- @session = session
604
- @session.visit('/with_js')
602
+ session.visit('/with_js')
605
603
  end
606
604
 
607
605
  it 'waits if wait time is more than timeout' do
608
- @session.click_link('Change page')
606
+ session.click_link('Change page')
609
607
  using_wait_time 0 do
610
- expect(@session).to have_current_path('/with_html', wait: 2)
608
+ expect(session).to have_current_path('/with_html', wait: 2)
611
609
  end
612
610
  end
613
611
 
614
612
  it "doesn't wait if wait time is less than timeout" do
615
- @session.click_link('Change page')
613
+ session.click_link('Change page')
616
614
  using_wait_time 0 do
617
- expect(@session).not_to have_current_path('/with_html')
615
+ expect(session).not_to have_current_path('/with_html')
618
616
  end
619
617
  end
620
618
  end
@@ -848,10 +846,11 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
848
846
  end
849
847
 
850
848
  context 'compounding timing' do
849
+ let(:session) { session }
850
+ let(:el) { session.find(:css, '#reload-me') }
851
+
851
852
  before do
852
- @session = session
853
- @session.visit('/with_js')
854
- @el = @session.find(:css, '#reload-me')
853
+ session.visit('/with_js')
855
854
  end
856
855
 
857
856
  context '#and' do
@@ -860,82 +859,82 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
860
859
  matcher = have_text('this is not there').and have_text('neither is this')
861
860
  expect(Benchmark.realtime do
862
861
  expect do
863
- expect(@el).to matcher
862
+ expect(el).to matcher
864
863
  end.to raise_error RSpec::Expectations::ExpectationNotMetError
865
864
  end).to be_between(2, 3)
866
865
  end
867
866
  end
868
867
 
869
868
  it "should run 'concurrently' and retry" do
870
- @session.click_link('reload-link')
871
- @session.using_wait_time(2) do
869
+ session.click_link('reload-link')
870
+ session.using_wait_time(2) do
872
871
  expect(Benchmark.realtime do
873
872
  expect do
874
- expect(@el).to have_text('waiting to be reloaded').and(have_text('has been reloaded'))
873
+ expect(el).to have_text('waiting to be reloaded').and(have_text('has been reloaded'))
875
874
  end.to raise_error RSpec::Expectations::ExpectationNotMetError, /expected to find text "waiting to be reloaded" in "has been reloaded"/
876
875
  end).to be_between(2, 3)
877
876
  end
878
877
  end
879
878
 
880
879
  it 'should ignore :wait options' do
881
- @session.using_wait_time(2) do
880
+ session.using_wait_time(2) do
882
881
  matcher = have_text('this is not there', wait: 5).and have_text('neither is this', wait: 6)
883
882
  expect(Benchmark.realtime do
884
883
  expect do
885
- expect(@el).to matcher
884
+ expect(el).to matcher
886
885
  end.to raise_error RSpec::Expectations::ExpectationNotMetError
887
886
  end).to be_between(2, 3)
888
887
  end
889
888
  end
890
889
 
891
890
  it 'should work on the session' do
892
- @session.using_wait_time(2) do
893
- @session.click_link('reload-link')
894
- expect(@session).to have_selector(:css, 'h1', text: 'FooBar').and have_text('has been reloaded')
891
+ session.using_wait_time(2) do
892
+ session.click_link('reload-link')
893
+ expect(session).to have_selector(:css, 'h1', text: 'FooBar').and have_text('has been reloaded')
895
894
  end
896
895
  end
897
896
  end
898
897
 
899
898
  context '#and_then' do
900
899
  it 'should run sequentially' do
901
- @session.click_link('reload-link')
902
- expect(@el).to have_text('waiting to be reloaded').and_then have_text('has been reloaded')
900
+ session.click_link('reload-link')
901
+ expect(el).to have_text('waiting to be reloaded').and_then have_text('has been reloaded')
903
902
  end
904
903
  end
905
904
 
906
905
  context '#or' do
907
906
  it "should run 'concurrently'" do
908
- @session.using_wait_time(3) do
907
+ session.using_wait_time(3) do
909
908
  expect(Benchmark.realtime do
910
- expect(@el).to have_text('has been reloaded').or have_text('waiting to be reloaded')
909
+ expect(el).to have_text('has been reloaded').or have_text('waiting to be reloaded')
911
910
  end).to be < 1
912
911
  end
913
912
  end
914
913
 
915
914
  it 'should retry' do
916
- @session.using_wait_time(3) do
915
+ session.using_wait_time(3) do
917
916
  expect(Benchmark.realtime do
918
917
  expect do
919
- expect(@el).to have_text('has been reloaded').or have_text('random stuff')
918
+ expect(el).to have_text('has been reloaded').or have_text('random stuff')
920
919
  end.to raise_error RSpec::Expectations::ExpectationNotMetError
921
920
  end).to be > 3
922
921
  end
923
922
  end
924
923
 
925
924
  it 'should ignore :wait options' do
926
- @session.using_wait_time(2) do
925
+ session.using_wait_time(2) do
927
926
  expect(Benchmark.realtime do
928
927
  expect do
929
- expect(@el).to have_text('this is not there', wait: 10).or have_text('neither is this', wait: 15)
928
+ expect(el).to have_text('this is not there', wait: 10).or have_text('neither is this', wait: 15)
930
929
  end.to raise_error RSpec::Expectations::ExpectationNotMetError
931
930
  end).to be_between(2, 3)
932
931
  end
933
932
  end
934
933
 
935
934
  it 'should work on the session' do
936
- @session.using_wait_time(2) do
937
- @session.click_link('reload-link')
938
- expect(@session).to have_selector(:css, 'h1', text: 'Not on the page').or have_text('has been reloaded')
935
+ session.using_wait_time(2) do
936
+ session.click_link('reload-link')
937
+ expect(session).to have_selector(:css, 'h1', text: 'Not on the page').or have_text('has been reloaded')
939
938
  end
940
939
  end
941
940
  end
@@ -75,40 +75,38 @@ RSpec.describe 'capybara/rspec' do
75
75
 
76
76
  context 'Type: Other', type: :other do
77
77
  context 'when RSpec::Matchers is included after Capybara::DSL' do
78
- before do
78
+ let(:test_class_instance) do
79
79
  class DSLMatchersTest
80
80
  include Capybara::DSL
81
81
  include RSpec::Matchers
82
- end
83
-
84
- @test_class_instance = DSLMatchersTest.new
82
+ end.new
85
83
  end
86
84
 
87
85
  context '#all' do
88
86
  it 'allows access to the Capybara finder' do
89
- @test_class_instance.visit('/with_html')
90
- expect(@test_class_instance.all(:css, 'h2.head').size).to eq(5)
87
+ test_class_instance.visit('/with_html')
88
+ expect(test_class_instance.all(:css, 'h2.head').size).to eq(5)
91
89
  end
92
90
 
93
91
  it 'allows access to the RSpec matcher' do
94
- @test_class_instance.visit('/with_html')
92
+ test_class_instance.visit('/with_html')
95
93
  strings = %w[test1 test2]
96
- expect(strings).to @test_class_instance.all(be_a(String))
94
+ expect(strings).to test_class_instance.all(be_a(String))
97
95
  end
98
96
  end
99
97
 
100
98
  context '#within' do
101
99
  it 'allows access to the Capybara scoper' do
102
- @test_class_instance.visit('/with_html')
100
+ test_class_instance.visit('/with_html')
103
101
  expect do
104
- @test_class_instance.within(:css, '#does_not_exist') { @test_class_instance.click_link 'Go to simple' }
102
+ test_class_instance.within(:css, '#does_not_exist') { test_class_instance.click_link 'Go to simple' }
105
103
  end.to raise_error(Capybara::ElementNotFound)
106
104
  end
107
105
 
108
106
  it 'allows access to the RSpec matcher' do
109
- @test_class_instance.visit('/with_html')
107
+ test_class_instance.visit('/with_html')
110
108
  # This reads terribly, but must call #within
111
- expect(@test_class_instance.find(:css, 'span.number').text.to_i).to @test_class_instance.within(1).of(41)
109
+ expect(test_class_instance.find(:css, 'span.number').text.to_i).to test_class_instance.within(1).of(41)
112
110
  end
113
111
  end
114
112
 
@@ -124,7 +122,7 @@ RSpec.describe 'capybara/rspec' do
124
122
  it 'can be called with `not_to`' do
125
123
  # This test is for a bug in jruby where `super` isn't defined correctly - https://github.com/jruby/jruby/issues/4678
126
124
  # Reported in https://github.com/teamcapybara/capybara/issues/2115
127
- @test_class_instance.instance_eval do
125
+ test_class_instance.instance_eval do
128
126
  expect do
129
127
  expect(true).not_to only_match_matcher(false) # rubocop:disable RSpec/ExpectActual
130
128
  end.not_to raise_error
@@ -42,6 +42,27 @@ RSpec.describe Capybara do
42
42
  <table>
43
43
  <tr><td></td></tr>
44
44
  </table>
45
+ <table id="rows">
46
+ <tr>
47
+ <td>A</td><td>B</td><td>C</td>
48
+ </tr>
49
+ <tr>
50
+ <td>D</td><td>E</td><td>F</td>
51
+ </tr>
52
+ </table>
53
+ <table id="cols">
54
+ <tbody>
55
+ <tr>
56
+ <td>A</td><td>D</td>
57
+ </tr>
58
+ <tr>
59
+ <td>B</td><td>E</td>
60
+ </tr>
61
+ <tr>
62
+ <td>C</td><td>F</td>
63
+ </tr>
64
+ </tbody>
65
+ </table>
45
66
  </body>
46
67
  </html>
47
68
  STRING
@@ -467,6 +488,16 @@ RSpec.describe Capybara do
467
488
  end
468
489
  end
469
490
  end
491
+
492
+ describe ':table selector' do
493
+ it 'finds by rows' do
494
+ expect(string.find(:table, with_rows: [%w[D E F]])[:id]).to eq 'rows'
495
+ end
496
+
497
+ it 'finds by columns' do
498
+ expect(string.find(:table, with_cols: [%w[A B C]])[:id]).to eq 'cols'
499
+ end
500
+ end
470
501
  end
471
502
  end
472
503
  end
@@ -50,23 +50,23 @@ RSpec.describe 'Capybara::Session with chrome' do
50
50
  context 'storage' do
51
51
  describe '#reset!' do
52
52
  it 'clears storage by default' do
53
- @session = TestSessions::Chrome
54
- @session.visit('/with_js')
55
- @session.find(:css, '#set-storage').click
56
- @session.reset!
57
- @session.visit('/with_js')
58
- expect(@session.evaluate_script('Object.keys(localStorage)')).to be_empty
59
- expect(@session.evaluate_script('Object.keys(sessionStorage)')).to be_empty
53
+ session = TestSessions::Chrome
54
+ session.visit('/with_js')
55
+ session.find(:css, '#set-storage').click
56
+ session.reset!
57
+ session.visit('/with_js')
58
+ expect(session.evaluate_script('Object.keys(localStorage)')).to be_empty
59
+ expect(session.evaluate_script('Object.keys(sessionStorage)')).to be_empty
60
60
  end
61
61
 
62
62
  it 'does not clear storage when false' do
63
- @session = Capybara::Session.new(:selenium_chrome_not_clear_storage, TestApp)
64
- @session.visit('/with_js')
65
- @session.find(:css, '#set-storage').click
66
- @session.reset!
67
- @session.visit('/with_js')
68
- expect(@session.evaluate_script('Object.keys(localStorage)')).not_to be_empty
69
- expect(@session.evaluate_script('Object.keys(sessionStorage)')).not_to be_empty
63
+ session = Capybara::Session.new(:selenium_chrome_not_clear_storage, TestApp)
64
+ session.visit('/with_js')
65
+ session.find(:css, '#set-storage').click
66
+ session.reset!
67
+ session.visit('/with_js')
68
+ expect(session.evaluate_script('Object.keys(localStorage)')).not_to be_empty
69
+ expect(session.evaluate_script('Object.keys(sessionStorage)')).not_to be_empty
70
70
  end
71
71
  end
72
72
  end
@@ -79,29 +79,29 @@ RSpec.describe 'Capybara::Session with chrome' do
79
79
 
80
80
  describe 'filling in Chrome-specific date and time fields with keystrokes' do
81
81
  let(:datetime) { Time.new(1983, 6, 19, 6, 30) }
82
+ let(:session) { TestSessions::Chrome }
82
83
 
83
84
  before do
84
- @session = TestSessions::Chrome
85
- @session.visit('/form')
85
+ session.visit('/form')
86
86
  end
87
87
 
88
88
  it 'should fill in a date input with a String' do
89
- @session.fill_in('form_date', with: '06/19/1983')
90
- @session.click_button('awesome')
91
- expect(Date.parse(extract_results(@session)['date'])).to eq datetime.to_date
89
+ session.fill_in('form_date', with: '06/19/1983')
90
+ session.click_button('awesome')
91
+ expect(Date.parse(extract_results(session)['date'])).to eq datetime.to_date
92
92
  end
93
93
 
94
94
  it 'should fill in a time input with a String' do
95
- @session.fill_in('form_time', with: '06:30A')
96
- @session.click_button('awesome')
97
- results = extract_results(@session)['time']
95
+ session.fill_in('form_time', with: '06:30A')
96
+ session.click_button('awesome')
97
+ results = extract_results(session)['time']
98
98
  expect(Time.parse(results).strftime('%r')).to eq datetime.strftime('%r')
99
99
  end
100
100
 
101
101
  it 'should fill in a datetime input with a String' do
102
- @session.fill_in('form_datetime', with: "06/19/1983\t06:30A")
103
- @session.click_button('awesome')
104
- expect(Time.parse(extract_results(@session)['datetime'])).to eq datetime
102
+ session.fill_in('form_datetime', with: "06/19/1983\t06:30A")
103
+ session.click_button('awesome')
104
+ expect(Time.parse(extract_results(session)['datetime'])).to eq datetime
105
105
  end
106
106
  end
107
107
  end
@@ -64,6 +64,8 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumFirefox, 'selenium', capyba
64
64
  skip 'Need to figure out testing of file downloading on windows platform' if Gem.win_platform?
65
65
  when 'Capybara::Session selenium #reset_session! removes ALL cookies'
66
66
  pending "Geckodriver doesn't provide a way to remove cookies outside the current domain"
67
+ when 'Capybara::Session selenium #attach_file with a block can upload by clicking the file input'
68
+ pending "Geckodriver doesn't allow clicking on file inputs"
67
69
  end
68
70
  end
69
71
 
@@ -71,54 +73,79 @@ RSpec.describe 'Capybara::Session with firefox' do # rubocop:disable RSpec/Multi
71
73
  include Capybara::SpecHelper
72
74
  include_examples 'Capybara::Session', TestSessions::SeleniumFirefox, :selenium_firefox
73
75
  include_examples Capybara::RSpecMatchers, TestSessions::SeleniumFirefox, :selenium_firefox
76
+
77
+ describe 'filling in Firefox-specific date and time fields with keystrokes' do
78
+ let(:datetime) { Time.new(1983, 6, 19, 6, 30) }
79
+ let(:session) { TestSessions::SeleniumFirefox }
80
+
81
+ before do
82
+ session.visit('/form')
83
+ end
84
+
85
+ it 'should fill in a date input with a String' do
86
+ session.fill_in('form_date', with: datetime.to_date.iso8601)
87
+ session.click_button('awesome')
88
+ expect(Date.parse(extract_results(session)['date'])).to eq datetime.to_date
89
+ end
90
+
91
+ it 'should fill in a time input with a String' do
92
+ session.fill_in('form_time', with: datetime.to_time.strftime('%T'))
93
+ session.click_button('awesome')
94
+ results = extract_results(session)['time']
95
+ expect(Time.parse(results).strftime('%r')).to eq datetime.strftime('%r')
96
+ end
97
+
98
+ it 'should fill in a datetime input with a String' do
99
+ # FF doesn't currently support datetime-local so this is really just a text input
100
+ session.fill_in('form_datetime', with: datetime.iso8601)
101
+ session.click_button('awesome')
102
+ expect(Time.parse(extract_results(session)['datetime'])).to eq datetime
103
+ end
104
+ end
74
105
  end
75
106
 
76
107
  RSpec.describe Capybara::Selenium::Driver do
77
- before do
78
- @driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox, options: browser_options)
79
- end
108
+ let(:driver) { Capybara::Selenium::Driver.new(TestApp, browser: :firefox, options: browser_options) }
80
109
 
81
110
  describe '#quit' do
82
111
  it 'should reset browser when quit' do
83
- expect(@driver.browser).to be_truthy
84
- @driver.quit
112
+ expect(driver.browser).to be_truthy
113
+ driver.quit
85
114
  # access instance variable directly so we don't create a new browser instance
86
- expect(@driver.instance_variable_get(:@browser)).to be_nil
115
+ expect(driver.instance_variable_get(:@browser)).to be_nil
87
116
  end
88
117
 
89
118
  context 'with errors' do
90
- before do
91
- @original_browser = @driver.browser
92
- end
119
+ let!(:original_browser) { driver.browser }
93
120
 
94
121
  after do
95
122
  # Ensure browser is actually quit so we don't leave hanging processe
96
- RSpec::Mocks.space.proxy_for(@original_browser).reset
97
- @original_browser.quit
123
+ RSpec::Mocks.space.proxy_for(original_browser).reset
124
+ original_browser.quit
98
125
  end
99
126
 
100
127
  it 'warns UnknownError returned during quit because the browser is probably already gone' do
101
- allow(@driver).to receive(:warn)
102
- allow(@driver.browser).to(
128
+ allow(driver).to receive(:warn)
129
+ allow(driver.browser).to(
103
130
  receive(:quit)
104
131
  .and_raise(Selenium::WebDriver::Error::UnknownError, 'random message')
105
132
  )
106
133
 
107
- expect { @driver.quit }.not_to raise_error
108
- expect(@driver.instance_variable_get(:@browser)).to be_nil
109
- expect(@driver).to have_received(:warn).with(/random message/)
134
+ expect { driver.quit }.not_to raise_error
135
+ expect(driver.instance_variable_get(:@browser)).to be_nil
136
+ expect(driver).to have_received(:warn).with(/random message/)
110
137
  end
111
138
 
112
139
  it 'ignores silenced UnknownError returned during quit because the browser is almost definitely already gone' do
113
- allow(@driver).to receive(:warn)
114
- allow(@driver.browser).to(
140
+ allow(driver).to receive(:warn)
141
+ allow(driver.browser).to(
115
142
  receive(:quit)
116
143
  .and_raise(Selenium::WebDriver::Error::UnknownError, 'Error communicating with the remote browser')
117
144
  )
118
145
 
119
- expect { @driver.quit }.not_to raise_error
120
- expect(@driver.instance_variable_get(:@browser)).to be_nil
121
- expect(@driver).not_to have_received(:warn)
146
+ expect { driver.quit }.not_to raise_error
147
+ expect(driver.instance_variable_get(:@browser)).to be_nil
148
+ expect(driver).not_to have_received(:warn)
122
149
  end
123
150
  end
124
151
  end
@@ -126,23 +153,23 @@ RSpec.describe Capybara::Selenium::Driver do
126
153
  context 'storage' do
127
154
  describe '#reset!' do
128
155
  it 'clears storage by default' do
129
- @session = TestSessions::SeleniumFirefox
130
- @session.visit('/with_js')
131
- @session.find(:css, '#set-storage').click
132
- @session.reset!
133
- @session.visit('/with_js')
134
- expect(@session.driver.browser.local_storage.keys).to be_empty
135
- expect(@session.driver.browser.session_storage.keys).to be_empty
156
+ session = TestSessions::SeleniumFirefox
157
+ session.visit('/with_js')
158
+ session.find(:css, '#set-storage').click
159
+ session.reset!
160
+ session.visit('/with_js')
161
+ expect(session.driver.browser.local_storage.keys).to be_empty
162
+ expect(session.driver.browser.session_storage.keys).to be_empty
136
163
  end
137
164
 
138
165
  it 'does not clear storage when false' do
139
- @session = Capybara::Session.new(:selenium_firefox_not_clear_storage, TestApp)
140
- @session.visit('/with_js')
141
- @session.find(:css, '#set-storage').click
142
- @session.reset!
143
- @session.visit('/with_js')
144
- expect(@session.driver.browser.local_storage.keys).not_to be_empty
145
- expect(@session.driver.browser.session_storage.keys).not_to be_empty
166
+ session = Capybara::Session.new(:selenium_firefox_not_clear_storage, TestApp)
167
+ session.visit('/with_js')
168
+ session.find(:css, '#set-storage').click
169
+ session.reset!
170
+ session.visit('/with_js')
171
+ expect(session.driver.browser.local_storage.keys).not_to be_empty
172
+ expect(session.driver.browser.session_storage.keys).not_to be_empty
146
173
  end
147
174
  end
148
175
  end