capybara 3.3.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +16 -0
  3. data/README.md +5 -7
  4. data/lib/capybara.rb +7 -6
  5. data/lib/capybara/config.rb +1 -1
  6. data/lib/capybara/dsl.rb +2 -2
  7. data/lib/capybara/helpers.rb +3 -3
  8. data/lib/capybara/minitest/spec.rb +3 -3
  9. data/lib/capybara/node/actions.rb +18 -18
  10. data/lib/capybara/node/base.rb +1 -1
  11. data/lib/capybara/node/element.rb +2 -2
  12. data/lib/capybara/node/finders.rb +6 -6
  13. data/lib/capybara/node/matchers.rb +5 -5
  14. data/lib/capybara/node/simple.rb +2 -2
  15. data/lib/capybara/queries/ancestor_query.rb +1 -1
  16. data/lib/capybara/queries/base_query.rb +12 -11
  17. data/lib/capybara/queries/current_path_query.rb +1 -1
  18. data/lib/capybara/queries/selector_query.rb +39 -15
  19. data/lib/capybara/queries/sibling_query.rb +1 -1
  20. data/lib/capybara/queries/text_query.rb +1 -1
  21. data/lib/capybara/rack_test/browser.rb +7 -7
  22. data/lib/capybara/rack_test/driver.rb +1 -1
  23. data/lib/capybara/rack_test/form.rb +7 -7
  24. data/lib/capybara/rack_test/node.rb +16 -16
  25. data/lib/capybara/rails.rb +1 -1
  26. data/lib/capybara/result.rb +8 -4
  27. data/lib/capybara/rspec/features.rb +4 -4
  28. data/lib/capybara/rspec/matchers.rb +6 -6
  29. data/lib/capybara/selector.rb +106 -90
  30. data/lib/capybara/selector/css.rb +4 -4
  31. data/lib/capybara/selector/filter_set.rb +52 -8
  32. data/lib/capybara/selector/selector.rb +39 -15
  33. data/lib/capybara/selenium/driver.rb +10 -10
  34. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +8 -0
  35. data/lib/capybara/selenium/node.rb +9 -10
  36. data/lib/capybara/selenium/nodes/chrome_node.rb +18 -0
  37. data/lib/capybara/selenium/nodes/marionette_node.rb +32 -7
  38. data/lib/capybara/server.rb +3 -3
  39. data/lib/capybara/server/animation_disabler.rb +1 -1
  40. data/lib/capybara/server/middleware.rb +1 -1
  41. data/lib/capybara/session.rb +23 -19
  42. data/lib/capybara/session/config.rb +18 -3
  43. data/lib/capybara/spec/public/test.js +1 -1
  44. data/lib/capybara/spec/session/accept_alert_spec.rb +10 -10
  45. data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -3
  46. data/lib/capybara/spec/session/accept_prompt_spec.rb +9 -10
  47. data/lib/capybara/spec/session/all_spec.rb +33 -32
  48. data/lib/capybara/spec/session/ancestor_spec.rb +19 -19
  49. data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +38 -38
  50. data/lib/capybara/spec/session/assert_current_path_spec.rb +16 -16
  51. data/lib/capybara/spec/session/assert_selector_spec.rb +53 -53
  52. data/lib/capybara/spec/session/assert_style_spec.rb +3 -3
  53. data/lib/capybara/spec/session/assert_text_spec.rb +31 -30
  54. data/lib/capybara/spec/session/assert_title_spec.rb +12 -12
  55. data/lib/capybara/spec/session/attach_file_spec.rb +51 -52
  56. data/lib/capybara/spec/session/body_spec.rb +6 -6
  57. data/lib/capybara/spec/session/check_spec.rb +52 -47
  58. data/lib/capybara/spec/session/choose_spec.rb +32 -32
  59. data/lib/capybara/spec/session/click_button_spec.rb +103 -103
  60. data/lib/capybara/spec/session/click_link_or_button_spec.rb +24 -23
  61. data/lib/capybara/spec/session/click_link_spec.rb +49 -48
  62. data/lib/capybara/spec/session/current_scope_spec.rb +7 -7
  63. data/lib/capybara/spec/session/current_url_spec.rb +26 -27
  64. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +3 -3
  65. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +2 -2
  66. data/lib/capybara/spec/session/element/assert_match_selector_spec.rb +8 -8
  67. data/lib/capybara/spec/session/element/match_css_spec.rb +10 -10
  68. data/lib/capybara/spec/session/element/match_xpath_spec.rb +6 -6
  69. data/lib/capybara/spec/session/element/matches_selector_spec.rb +51 -51
  70. data/lib/capybara/spec/session/evaluate_async_script_spec.rb +7 -7
  71. data/lib/capybara/spec/session/evaluate_script_spec.rb +15 -8
  72. data/lib/capybara/spec/session/execute_script_spec.rb +7 -7
  73. data/lib/capybara/spec/session/fill_in_spec.rb +43 -42
  74. data/lib/capybara/spec/session/find_button_spec.rb +23 -23
  75. data/lib/capybara/spec/session/find_by_id_spec.rb +7 -7
  76. data/lib/capybara/spec/session/find_field_spec.rb +32 -30
  77. data/lib/capybara/spec/session/find_link_spec.rb +21 -21
  78. data/lib/capybara/spec/session/find_spec.rb +153 -135
  79. data/lib/capybara/spec/session/first_spec.rb +41 -41
  80. data/lib/capybara/spec/session/frame/frame_title_spec.rb +5 -5
  81. data/lib/capybara/spec/session/frame/frame_url_spec.rb +5 -5
  82. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +17 -17
  83. data/lib/capybara/spec/session/frame/within_frame_spec.rb +31 -17
  84. data/lib/capybara/spec/session/go_back_spec.rb +1 -1
  85. data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
  86. data/lib/capybara/spec/session/has_all_selectors_spec.rb +17 -17
  87. data/lib/capybara/spec/session/has_button_spec.rb +13 -13
  88. data/lib/capybara/spec/session/has_css_spec.rb +133 -131
  89. data/lib/capybara/spec/session/has_current_path_spec.rb +29 -29
  90. data/lib/capybara/spec/session/has_field_spec.rb +58 -58
  91. data/lib/capybara/spec/session/has_link_spec.rb +4 -4
  92. data/lib/capybara/spec/session/has_none_selectors_spec.rb +24 -24
  93. data/lib/capybara/spec/session/has_select_spec.rb +43 -43
  94. data/lib/capybara/spec/session/has_selector_spec.rb +71 -71
  95. data/lib/capybara/spec/session/has_style_spec.rb +3 -3
  96. data/lib/capybara/spec/session/has_table_spec.rb +4 -4
  97. data/lib/capybara/spec/session/has_text_spec.rb +53 -52
  98. data/lib/capybara/spec/session/has_title_spec.rb +14 -14
  99. data/lib/capybara/spec/session/has_xpath_spec.rb +39 -38
  100. data/lib/capybara/spec/session/headers_spec.rb +1 -1
  101. data/lib/capybara/spec/session/html_spec.rb +6 -6
  102. data/lib/capybara/spec/session/node_spec.rb +129 -123
  103. data/lib/capybara/spec/session/node_wrapper_spec.rb +10 -7
  104. data/lib/capybara/spec/session/refresh_spec.rb +4 -7
  105. data/lib/capybara/spec/session/reset_session_spec.rb +28 -28
  106. data/lib/capybara/spec/session/response_code_spec.rb +1 -1
  107. data/lib/capybara/spec/session/save_and_open_page_spec.rb +2 -2
  108. data/lib/capybara/spec/session/save_page_spec.rb +37 -37
  109. data/lib/capybara/spec/session/save_screenshot_spec.rb +6 -6
  110. data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
  111. data/lib/capybara/spec/session/select_spec.rb +81 -81
  112. data/lib/capybara/spec/session/selectors_spec.rb +17 -17
  113. data/lib/capybara/spec/session/sibling_spec.rb +9 -9
  114. data/lib/capybara/spec/session/text_spec.rb +23 -23
  115. data/lib/capybara/spec/session/title_spec.rb +5 -5
  116. data/lib/capybara/spec/session/uncheck_spec.rb +24 -20
  117. data/lib/capybara/spec/session/unselect_spec.rb +37 -37
  118. data/lib/capybara/spec/session/visit_spec.rb +48 -49
  119. data/lib/capybara/spec/session/window/current_window_spec.rb +1 -1
  120. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -16
  121. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -2
  122. data/lib/capybara/spec/session/window/window_spec.rb +4 -4
  123. data/lib/capybara/spec/session/window/within_window_spec.rb +14 -14
  124. data/lib/capybara/spec/session/within_spec.rb +41 -41
  125. data/lib/capybara/spec/spec_helper.rb +11 -9
  126. data/lib/capybara/spec/test_app.rb +18 -17
  127. data/lib/capybara/spec/views/form.erb +29 -31
  128. data/lib/capybara/spec/views/with_html.erb +2 -2
  129. data/lib/capybara/version.rb +1 -1
  130. data/spec/basic_node_spec.rb +23 -23
  131. data/spec/capybara_spec.rb +20 -20
  132. data/spec/css_splitter_spec.rb +7 -7
  133. data/spec/dsl_spec.rb +37 -32
  134. data/spec/filter_set_spec.rb +4 -4
  135. data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
  136. data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
  137. data/spec/minitest_spec.rb +4 -4
  138. data/spec/minitest_spec_spec.rb +23 -23
  139. data/spec/per_session_config_spec.rb +5 -5
  140. data/spec/rack_test_spec.rb +44 -44
  141. data/spec/result_spec.rb +14 -14
  142. data/spec/rspec/features_spec.rb +13 -13
  143. data/spec/rspec/scenarios_spec.rb +4 -4
  144. data/spec/rspec/shared_spec_matchers.rb +282 -281
  145. data/spec/rspec/views_spec.rb +3 -3
  146. data/spec/rspec_matchers_spec.rb +10 -10
  147. data/spec/rspec_spec.rb +29 -29
  148. data/spec/selector_spec.rb +64 -64
  149. data/spec/selenium_spec_chrome.rb +14 -22
  150. data/spec/selenium_spec_chrome_remote.rb +28 -8
  151. data/spec/selenium_spec_edge.rb +9 -4
  152. data/spec/selenium_spec_firefox_remote.rb +87 -0
  153. data/spec/selenium_spec_ie.rb +9 -4
  154. data/spec/selenium_spec_marionette.rb +42 -18
  155. data/spec/server_spec.rb +29 -27
  156. data/spec/session_spec.rb +17 -17
  157. data/spec/shared_selenium_session.rb +70 -52
  158. data/spec/spec_helper.rb +1 -1
  159. metadata +4 -2
@@ -3,28 +3,28 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Capybara::Session do
6
- context "#new" do
7
- it "should raise an error if passed non-existent driver" do
6
+ context '#new' do
7
+ it 'should raise an error if passed non-existent driver' do
8
8
  expect do
9
9
  Capybara::Session.new(:quox, TestApp).driver
10
10
  end.to raise_error(Capybara::DriverNotFoundError)
11
11
  end
12
12
 
13
- it "verifies a passed app is a rack app" do
13
+ it 'verifies a passed app is a rack app' do
14
14
  expect do
15
- Capybara::Session.new(:unknown, random: "hash")
16
- end.to raise_error TypeError, "The second parameter to Session::new should be a rack app if passed."
15
+ Capybara::Session.new(:unknown, random: 'hash')
16
+ end.to raise_error TypeError, 'The second parameter to Session::new should be a rack app if passed.'
17
17
  end
18
18
  end
19
19
 
20
- context "current_driver" do
20
+ context 'current_driver' do
21
21
  around do |example|
22
22
  orig_driver = Capybara.current_driver
23
23
  example.run
24
24
  Capybara.current_driver = orig_driver
25
25
  end
26
26
 
27
- it "is global when threadsafe false" do
27
+ it 'is global when threadsafe false' do
28
28
  Capybara.threadsafe = false
29
29
  Capybara.current_driver = :selenium
30
30
  thread = Thread.new do
@@ -34,7 +34,7 @@ RSpec.describe Capybara::Session do
34
34
  expect(Capybara.current_driver).to eq :random
35
35
  end
36
36
 
37
- it "is thread specific threadsafe true" do
37
+ it 'is thread specific threadsafe true' do
38
38
  Capybara.threadsafe = true
39
39
  Capybara.current_driver = :selenium
40
40
  thread = Thread.new do
@@ -45,31 +45,31 @@ RSpec.describe Capybara::Session do
45
45
  end
46
46
  end
47
47
 
48
- context "session_name" do
48
+ context 'session_name' do
49
49
  around do |example|
50
50
  orig_name = Capybara.session_name
51
51
  example.run
52
52
  Capybara.session_name = orig_name
53
53
  end
54
54
 
55
- it "is global when threadsafe false" do
55
+ it 'is global when threadsafe false' do
56
56
  Capybara.threadsafe = false
57
- Capybara.session_name = "sess1"
57
+ Capybara.session_name = 'sess1'
58
58
  thread = Thread.new do
59
- Capybara.session_name = "sess2"
59
+ Capybara.session_name = 'sess2'
60
60
  end
61
61
  thread.join
62
- expect(Capybara.session_name).to eq "sess2"
62
+ expect(Capybara.session_name).to eq 'sess2'
63
63
  end
64
64
 
65
- it "is thread specific when threadsafe true" do
65
+ it 'is thread specific when threadsafe true' do
66
66
  Capybara.threadsafe = true
67
- Capybara.session_name = "sess1"
67
+ Capybara.session_name = 'sess1'
68
68
  thread = Thread.new do
69
- Capybara.session_name = "sess2"
69
+ Capybara.session_name = 'sess2'
70
70
  end
71
71
  thread.join
72
- expect(Capybara.session_name).to eq "sess1"
72
+ expect(Capybara.session_name).to eq 'sess1'
73
73
  end
74
74
  end
75
75
  end
@@ -1,33 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
- require "selenium-webdriver"
4
+ require 'selenium-webdriver'
5
5
 
6
- RSpec.shared_examples "Capybara::Session" do |session, mode|
6
+ RSpec.shared_examples 'Capybara::Session' do |session, mode|
7
7
  let(:session) { session }
8
8
 
9
9
  context 'with selenium driver' do
10
10
  describe '#driver' do
11
- it "should be a selenium driver" do
11
+ it 'should be a selenium driver' do
12
12
  expect(session.driver).to be_an_instance_of(Capybara::Selenium::Driver)
13
13
  end
14
14
  end
15
15
 
16
16
  describe '#mode' do
17
- it "should remember the mode" do
17
+ it 'should remember the mode' do
18
18
  expect(session.mode).to eq(mode)
19
19
  end
20
20
  end
21
21
 
22
- describe "#reset!" do
23
- it "freshly reset session should not be touched" do
22
+ describe '#reset!' do
23
+ it 'freshly reset session should not be touched' do
24
24
  session.instance_variable_set(:@touched, true)
25
25
  session.reset!
26
26
  expect(session.instance_variable_get(:@touched)).to eq false
27
27
  end
28
28
  end
29
29
 
30
- describe "exit codes" do
30
+ describe 'exit codes' do
31
31
  before do
32
32
  @current_dir = Dir.getwd
33
33
  Dir.chdir(File.join(File.dirname(__FILE__), '..'))
@@ -38,14 +38,14 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
38
38
  Dir.chdir(@current_dir)
39
39
  end
40
40
 
41
- it "should have return code 1 when running selenium_driver_rspec_failure.rb" do
41
+ it 'should have return code 1 when running selenium_driver_rspec_failure.rb' do
42
42
  skip if headless_or_remote?
43
43
 
44
44
  system(@env, 'rspec spec/fixtures/selenium_driver_rspec_failure.rb', out: File::NULL, err: File::NULL)
45
45
  expect($CHILD_STATUS.exitstatus).to eq(1)
46
46
  end
47
47
 
48
- it "should have return code 0 when running selenium_driver_rspec_success.rb" do
48
+ it 'should have return code 0 when running selenium_driver_rspec_success.rb' do
49
49
  skip if headless_or_remote?
50
50
 
51
51
  system(@env, 'rspec spec/fixtures/selenium_driver_rspec_success.rb', out: File::NULL, err: File::NULL)
@@ -53,16 +53,16 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
53
53
  end
54
54
  end
55
55
 
56
- describe "#accept_alert", requires: [:modals] do
57
- it "supports a blockless mode" do
56
+ describe '#accept_alert', requires: [:modals] do
57
+ it 'supports a blockless mode' do
58
58
  session.visit('/with_js')
59
59
  session.click_link('Open alert')
60
60
  session.accept_alert
61
61
  expect { session.driver.browser.switch_to.alert }.to raise_error(session.driver.send(:modal_error))
62
62
  end
63
63
 
64
- it "can be called before visiting" do
65
- session.accept_alert "Initial alert" do
64
+ it 'can be called before visiting' do
65
+ session.accept_alert 'Initial alert' do
66
66
  session.visit('/initial_alert')
67
67
  end
68
68
  expect(session).to have_text('Initial alert page')
@@ -79,7 +79,12 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
79
79
  end
80
80
  end
81
81
 
82
- context "#fill_in with { :clear => :backspace } fill_option", requires: [:js] do
82
+ context '#fill_in with { :clear => :backspace } fill_option', requires: [:js] do
83
+ before do
84
+ # Firefox has an issue with change events if the main window doesn't think it's focused
85
+ session.execute_script('window.focus()')
86
+ end
87
+
83
88
  it 'should fill in a field, replacing an existing value' do
84
89
  session.visit('/form')
85
90
  session.fill_in('form_first_name',
@@ -88,6 +93,19 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
88
93
  expect(session.find(:fillable_field, 'form_first_name').value).to eq('Harry')
89
94
  end
90
95
 
96
+ it 'should fill in a field, replacing an existing value, even with caret position' do
97
+ session.visit('/form')
98
+ session.find(:css, '#form_first_name').execute_script <<-JS
99
+ this.focus();
100
+ this.setSelectionRange(0, 0);
101
+ JS
102
+
103
+ session.fill_in('form_first_name',
104
+ with: 'Harry',
105
+ fill_options: { clear: :backspace })
106
+ expect(session.find(:fillable_field, 'form_first_name').value).to eq('Harry')
107
+ end
108
+
91
109
  it 'should fill in if the option is set via global option' do
92
110
  Capybara.default_set_options = { clear: :backspace }
93
111
  session.visit('/form')
@@ -101,8 +119,8 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
101
119
  with: 'some value',
102
120
  fill_options: { clear: :backspace })
103
121
  # click outside the field to trigger the change event
104
- session.find(:css, 'body').click
105
- expect(session.find(:css, '.change_event_triggered', match: :one)).to have_text 'some value'
122
+ session.find(:css, '#with_focus_event').click
123
+ expect(session.find(:css, '.change_event_triggered', match: :one, wait: 5)).to have_text 'some value'
106
124
  end
107
125
 
108
126
  it 'should trigger change when clearing field' do
@@ -111,8 +129,8 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
111
129
  with: '',
112
130
  fill_options: { clear: :backspace })
113
131
  # click outside the field to trigger the change event
114
- session.find(:css, 'body').click
115
- expect(session).to have_selector(:css, '.change_event_triggered', match: :one)
132
+ session.find(:css, '#with_focus_event').click
133
+ expect(session).to have_selector(:css, '.change_event_triggered', match: :one, wait: 5)
116
134
  end
117
135
 
118
136
  it 'should trigger input event field_value.length times' do
@@ -126,7 +144,7 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
126
144
  end
127
145
  end
128
146
 
129
- context "#fill_in with { clear: :none } fill_options" do
147
+ context '#fill_in with { clear: :none } fill_options' do
130
148
  it 'should append to content in a field' do
131
149
  session.visit('/form')
132
150
  session.fill_in('form_first_name',
@@ -139,23 +157,23 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
139
157
  context '#fill_in with Date' do
140
158
  before do
141
159
  session.visit('/form')
142
- session.execute_script <<-JS
160
+ session.find(:css, '#form_date').execute_script <<-JS
143
161
  window.capybara_formDateFiredEvents = [];
162
+ var fd = this;
144
163
  ['focus', 'input', 'change'].forEach(function(eventType) {
145
- document.getElementById('form_date')
146
- .addEventListener(eventType, function() { window.capybara_formDateFiredEvents.push(eventType); });
164
+ fd.addEventListener(eventType, function() { window.capybara_formDateFiredEvents.push(eventType); });
147
165
  });
148
166
  JS
149
167
  # work around weird FF issue where it would create an extra focus issue in some cases
150
168
  session.find(:css, 'body').click
151
169
  end
152
170
 
153
- it "should generate standard events on changing value" do
171
+ it 'should generate standard events on changing value' do
154
172
  session.fill_in('form_date', with: Date.today)
155
173
  expect(session.evaluate_script('window.capybara_formDateFiredEvents')).to eq %w[focus input change]
156
174
  end
157
175
 
158
- it "should not generate input and change events if the value is not changed" do
176
+ it 'should not generate input and change events if the value is not changed' do
159
177
  session.fill_in('form_date', with: Date.today)
160
178
  session.fill_in('form_date', with: Date.today)
161
179
  # Chrome adds an extra focus for some reason - ok for now
@@ -163,7 +181,7 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
163
181
  end
164
182
  end
165
183
 
166
- context "#fill_in with { clear: Array } fill_options" do
184
+ context '#fill_in with { clear: Array } fill_options' do
167
185
  it 'should pass the array through to the element' do
168
186
  pending "selenium-webdriver/geckodriver doesn't support complex sets of characters" if marionette?(session)
169
187
  # this is mainly for use with [[:control, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
@@ -175,53 +193,53 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
175
193
  end
176
194
  end
177
195
 
178
- describe "#path" do
179
- it "returns xpath" do
196
+ describe '#path' do
197
+ it 'returns xpath' do
180
198
  # this is here because it is testing for an XPath that is specific to the algorithm used in the selenium driver
181
199
  session.visit('/path')
182
200
  element = session.find(:link, 'Second Link')
183
201
  expect(element.path).to eq('/HTML/BODY/DIV[2]/A[1]')
184
202
  end
185
203
 
186
- it "handles namespaces" do
187
- session.visit "/with_namespace"
188
- rect = session.find(:css, "div svg rect")
204
+ it 'handles namespaces' do
205
+ session.visit '/with_namespace'
206
+ rect = session.find(:css, 'div svg rect')
189
207
  expect(rect.path).to eq("/HTML/BODY/DIV/./*[((local-name(.) = 'svg') and (namespace-uri(.) = 'http://www.w3.org/2000/svg'))]/./*[((local-name(.) = 'rect') and (namespace-uri(.) = 'http://www.w3.org/2000/svg'))][1]")
190
208
  expect(session.find(:xpath, rect.path)).to eq rect
191
209
  end
192
210
 
193
- it "handles case sensitive element names" do
194
- session.visit "/with_namespace"
195
- els = session.all(:css, "div *", visible: :all)
211
+ it 'handles case sensitive element names' do
212
+ session.visit '/with_namespace'
213
+ els = session.all(:css, 'div *', visible: :all)
196
214
  expect { els.map(&:path) }.not_to raise_error
197
- lg = session.find(:css, "div linearGradient", visible: :all)
215
+ lg = session.find(:css, 'div linearGradient', visible: :all)
198
216
  expect(session.find(:xpath, lg.path, visible: :all)).to eq lg
199
217
  end
200
218
  end
201
219
 
202
- describe "all with disappearing elements" do
203
- it "ignores stale elements in results" do
220
+ describe 'all with disappearing elements' do
221
+ it 'ignores stale elements in results' do
204
222
  session.visit('/path')
205
223
  elements = session.all(:link) { |_node| raise Selenium::WebDriver::Error::StaleElementReferenceError }
206
224
  expect(elements.size).to eq 0
207
225
  end
208
226
  end
209
227
 
210
- describe "#evaluate_script" do
211
- it "can return an element" do
228
+ describe '#evaluate_script' do
229
+ it 'can return an element' do
212
230
  session.visit('/form')
213
231
  element = session.evaluate_script("document.getElementById('form_title')")
214
232
  expect(element).to eq session.find(:id, 'form_title')
215
233
  end
216
234
 
217
- it "can return arrays of nested elements" do
235
+ it 'can return arrays of nested elements' do
218
236
  session.visit('/form')
219
237
  elements = session.evaluate_script('document.querySelectorAll("#form_city option")')
220
238
  expect(elements).to all(be_instance_of Capybara::Node::Element)
221
239
  expect(elements).to eq session.find(:css, '#form_city').all(:css, 'option').to_a
222
240
  end
223
241
 
224
- it "can return hashes with elements" do
242
+ it 'can return hashes with elements' do
225
243
  session.visit('/form')
226
244
  result = session.evaluate_script("{ a: document.getElementById('form_title'), b: {c: document.querySelectorAll('#form_city option')}}")
227
245
  expect(result).to eq(
@@ -232,31 +250,31 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
232
250
  )
233
251
  end
234
252
 
235
- describe "#evaluate_async_script" do
236
- it "will timeout if the script takes too long" do
253
+ describe '#evaluate_async_script' do
254
+ it 'will timeout if the script takes too long' do
237
255
  session.visit('/with_js')
238
256
  expect do
239
257
  session.using_wait_time(1) do
240
- session.evaluate_async_script("var cb = arguments[0]; setTimeout(function(){ cb(null) }, 3000)")
258
+ session.evaluate_async_script('var cb = arguments[0]; setTimeout(function(){ cb(null) }, 3000)')
241
259
  end
242
260
  end.to raise_error Selenium::WebDriver::Error::ScriptTimeoutError
243
261
  end
244
262
  end
245
263
  end
246
264
 
247
- describe "Element#inspect" do
248
- it "outputs obsolete elements" do
265
+ describe 'Element#inspect' do
266
+ it 'outputs obsolete elements' do
249
267
  session.visit('/form')
250
268
  el = session.find(:button, 'Click me!').click
251
269
  expect(session).to have_no_button('Click me!')
252
270
  allow(el).to receive(:synchronize)
253
- expect(el.inspect).to eq "Obsolete #<Capybara::Node::Element>"
271
+ expect(el.inspect).to eq 'Obsolete #<Capybara::Node::Element>'
254
272
  expect(el).not_to have_received(:synchronize)
255
273
  end
256
274
  end
257
275
 
258
- describe "Element#click" do
259
- it "should handle fixed headers/footers" do
276
+ describe 'Element#click' do
277
+ it 'should handle fixed headers/footers' do
260
278
  session.visit('/with_fixed_header_footer')
261
279
  # session.click_link('Go to root')
262
280
  session.find(:link, 'Go to root').click
@@ -264,7 +282,7 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
264
282
  end
265
283
  end
266
284
 
267
- context "Windows" do
285
+ context 'Windows' do
268
286
  it "can't close the primary window" do
269
287
  expect do
270
288
  session.current_window.close
@@ -272,7 +290,7 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
272
290
  end
273
291
  end
274
292
 
275
- context "AnimationDisabler" do
293
+ context 'AnimationDisabler' do
276
294
  before(:context) do # rubocop:disable RSpec/BeforeAfterAll
277
295
  Capybara.disable_animation = true
278
296
  @animation_session = Capybara::Session.new(session.mode, TestApp.new)
@@ -282,13 +300,13 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
282
300
  Capybara.disable_animation = false
283
301
  end
284
302
 
285
- it "should disable CSS transitions" do
303
+ it 'should disable CSS transitions' do
286
304
  @animation_session.visit('with_animation')
287
305
  @animation_session.click_link('transition me away')
288
306
  expect(@animation_session).to have_no_link('transition me away', wait: 0.5)
289
307
  end
290
308
 
291
- it "should disable CSS animations" do
309
+ it 'should disable CSS animations' do
292
310
  @animation_session.visit('with_animation')
293
311
  @animation_session.click_link('animate me away')
294
312
  expect(@animation_session).to have_no_link('animate me away', wait: 0.5)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rspec/expectations'
4
- require "capybara/spec/spec_helper"
4
+ require 'capybara/spec/spec_helper'
5
5
  require 'webdrivers' if ENV['CI']
6
6
 
7
7
  RSpec.configure do |config|
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: 3.3.1
4
+ version: 3.4.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: 2018-06-27 00:00:00.000000000 Z
13
+ date: 2018-07-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -312,6 +312,7 @@ files:
312
312
  - lib/capybara/selenium/driver_specializations/chrome_driver.rb
313
313
  - lib/capybara/selenium/driver_specializations/marionette_driver.rb
314
314
  - lib/capybara/selenium/node.rb
315
+ - lib/capybara/selenium/nodes/chrome_node.rb
315
316
  - lib/capybara/selenium/nodes/marionette_node.rb
316
317
  - lib/capybara/server.rb
317
318
  - lib/capybara/server/animation_disabler.rb
@@ -473,6 +474,7 @@ files:
473
474
  - spec/selenium_spec_chrome.rb
474
475
  - spec/selenium_spec_chrome_remote.rb
475
476
  - spec/selenium_spec_edge.rb
477
+ - spec/selenium_spec_firefox_remote.rb
476
478
  - spec/selenium_spec_ie.rb
477
479
  - spec/selenium_spec_marionette.rb
478
480
  - spec/server_spec.rb