capybara 3.32.0 → 3.32.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f60918220b590a4a64f3bb1a42b7e8c5dac86dddcec48d46c0f92c1ac6c491f
4
- data.tar.gz: aab5f09c11d94dc1becdb514d753011cdfad7f2a43f0e59b074ff6e69aa49847
3
+ metadata.gz: e457be34204bbe3a7127ca305fdc2f60be46ec3e92249d27ad351f6bd4473f67
4
+ data.tar.gz: 9549c4cdc7c22c4c6540c9177aed22bf57e5a5301e97a6e0f407a3a3ef6b0ac9
5
5
  SHA512:
6
- metadata.gz: 7adcf8fbe5fe95d42c3c7fe513f62236cf93dd0f95bbccb20d31c1022a5e87bd64514d2fd6f57a263d31b96945a2e1c7a300d6b16db018651b929abd137e8290
7
- data.tar.gz: d28874576cd8613f16b1d455785e4e6fba9cb387b8580ba0bdc0c46f13255661f07e47a51f5d7f2c28afa6691a4c330e094ff9625a89bb4f6f5d9532a3123063
6
+ metadata.gz: e6f30d47408a541fdc06b38e53f4a5f9d5cbaad05c1b2d450ea5e1edd101afb7188c6718727beaf232ecf94d595570f92dbe0f1b29d1769c94bf557b8542b335
7
+ data.tar.gz: 4cff5a7b19910ff7a136a8e3976194d381aef6e49715480a1b70ea6123412ac7020520eca499a7b717c6c05d578a3216763400e65e2afb7f7f3a1e7b825c3721
data/History.md CHANGED
@@ -1,5 +1,13 @@
1
+ # Version 3.32.1
2
+ Release date: 2020-04-05
3
+
4
+ ### Fixed
5
+
6
+ * Rapid set now respects field maxlength (Issue #2332)
7
+ * Only patch pause into legacy actions in Selenium < 4 (Issue #2334)
8
+
1
9
  # Version 3.32.0
2
- Relesae date: 2020-03-29
10
+ Release date: 2020-03-29
3
11
 
4
12
  ### Added
5
13
 
@@ -241,7 +241,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
241
241
 
242
242
  def quit
243
243
  @browser&.quit
244
- rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED # rubocop:disable Lint/SuppressedException
244
+ rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED
245
245
  # Browser must have already gone
246
246
  rescue Selenium::WebDriver::Error::UnknownError => e
247
247
  unless silenced_unknown_error_message?(e.message) # Most likely already gone
@@ -293,7 +293,7 @@ private
293
293
  def clear_browser_state
294
294
  delete_all_cookies
295
295
  clear_storage
296
- rescue *clear_browser_state_errors # rubocop:disable Lint/SuppressedException
296
+ rescue *clear_browser_state_errors
297
297
  # delete_all_cookies fails when we've previously gone
298
298
  # to about:blank, so we rescue this error and do nothing
299
299
  # instead.
@@ -317,7 +317,7 @@ private
317
317
  def clear_storage
318
318
  clear_session_storage unless options[:clear_session_storage] == false
319
319
  clear_local_storage unless options[:clear_local_storage] == false
320
- rescue Selenium::WebDriver::Error::JavascriptError # rubocop:disable Lint/SuppressedException
320
+ rescue Selenium::WebDriver::Error::JavascriptError
321
321
  # session/local storage may not be available if on non-http pages (e.g. about:blank)
322
322
  end
323
323
 
@@ -353,7 +353,7 @@ private
353
353
  @browser.navigate.to(url)
354
354
  sleep 0.1 # slight wait for alert
355
355
  @browser.switch_to.alert.accept
356
- rescue modal_error # rubocop:disable Lint/SuppressedException
356
+ rescue modal_error
357
357
  # alert now gone, should mean navigation happened
358
358
  end
359
359
 
@@ -46,7 +46,7 @@ module Capybara::Selenium::Driver::W3CFirefoxDriver
46
46
  begin
47
47
  # Firefox 68 hangs if we try to switch windows while a modal is visible
48
48
  browser.switch_to.alert&.dismiss
49
- rescue Selenium::WebDriver::Error::NoSuchAlertError # rubocop:disable Lint/SuppressedException
49
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
50
50
  # Swallow
51
51
  end
52
52
  end
@@ -61,7 +61,7 @@ module Capybara::Selenium::Driver::W3CFirefoxDriver
61
61
  accept_modal :confirm, wait: 0.1 do
62
62
  super
63
63
  end
64
- rescue Capybara::ModalNotFound # rubocop:disable Lint/SuppressedException
64
+ rescue Capybara::ModalNotFound
65
65
  # No modal was opened - page has refreshed - ignore
66
66
  end
67
67
 
@@ -237,7 +237,7 @@ protected
237
237
  JS
238
238
  begin
239
239
  driver.execute_script(script, self)
240
- rescue StandardError # rubocop:disable Lint/SuppressedException
240
+ rescue StandardError
241
241
  # Swallow error if scrollIntoView with options isn't supported
242
242
  end
243
243
  end
@@ -279,9 +279,9 @@ private
279
279
  send_keys(*clear, value)
280
280
  else
281
281
  driver.execute_script 'arguments[0].select()', self unless clear == :none
282
- if rapid == true || (value.length > 30 && rapid != false)
282
+ if rapid == true || ((value.length > auto_rapid_set_length) && rapid != false)
283
283
  send_keys(value[0..3])
284
- driver.execute_script 'arguments[0].value += arguments[1]', self, value[4...-3]
284
+ driver.execute_script RAPID_SET_TEXT, self, value[0...-3]
285
285
  send_keys(value[-3..-1])
286
286
  else
287
287
  send_keys(value)
@@ -289,6 +289,10 @@ private
289
289
  end
290
290
  end
291
291
 
292
+ def auto_rapid_set_length
293
+ 30
294
+ end
295
+
292
296
  def perform_with_options(click_options, &block)
293
297
  raise ArgumentError, 'A block must be provided' unless block
294
298
 
@@ -530,6 +534,15 @@ private
530
534
  })(arguments[0], arguments[1], arguments[2])
531
535
  JS
532
536
 
537
+ RAPID_SET_TEXT = <<~'JS'
538
+ (function(el, value) {
539
+ if (el.maxLength && el.maxLength != -1){
540
+ value = value.slice(0, el.maxLength);
541
+ }
542
+ el.value = value;
543
+ })(arguments[0], arguments[1])
544
+ JS
545
+
533
546
  # SettableValue encapsulates time/date field formatting
534
547
  class SettableValue
535
548
  attr_reader :value
@@ -20,4 +20,7 @@ module ActionPauser
20
20
  private_constant :Pauser
21
21
  end
22
22
 
23
- ::Selenium::WebDriver::ActionBuilder.prepend ActionPauser if defined? ::Selenium::WebDriver::ActionBuilder
23
+ if defined?(::Selenium::WebDriver::VERSION) && (::Selenium::WebDriver::VERSION.to_f < 4) &&
24
+ defined?(::Selenium::WebDriver::ActionBuilder)
25
+ ::Selenium::WebDriver::ActionBuilder.prepend(ActionPauser)
26
+ end
@@ -143,6 +143,10 @@
143
143
  <input type="text" maxlength="5" name="form[zipcode]" id="form_zipcode" />
144
144
  </p>
145
145
 
146
+ <p>
147
+ <input maxlength="35" id="long_length" />
148
+ </p>
149
+
146
150
  <p>
147
151
  <label for="form_tendency">Tendency</label>
148
152
  <select name="form[tendency]" id="form_tendency"></select>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Capybara
4
- VERSION = '3.32.0'
4
+ VERSION = '3.32.1'
5
5
  end
@@ -35,6 +35,16 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
35
35
  end
36
36
  end
37
37
 
38
+ describe '#set' do
39
+ it 'respects maxlength when using rapid set' do
40
+ session.visit('/form')
41
+ inp = session.find(:css, '#long_length')
42
+ value = (0...50).map { |i| ((i % 26) + 65).chr }.join
43
+ inp.set(value, rapid: true)
44
+ expect(inp.value).to eq value[0...35]
45
+ end
46
+ end
47
+
38
48
  describe '#visible?' do
39
49
  let(:bridge) do
40
50
  session.driver.browser.send(:bridge)
@@ -441,21 +441,30 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
441
441
  context 'controlled components' do
442
442
  it 'can set and clear a text field' do
443
443
  skip "This test doesn't support older browsers" if ie?(session)
444
- # session.visit 'https://reactjs.org/docs/forms.html'
445
- # session.all(:css, 'h2#controlled-components ~ p a', text: 'Try it on CodePen')[0].click
446
- # copied into local view
444
+
447
445
  session.visit 'react'
448
- # Not necessary when accessed locally
449
- # session.within_frame(:css, 'iframe.result-iframe:not([src=""])', wait: 10) do
446
+
450
447
  session.fill_in('Name:', with: 'abc')
451
448
  session.accept_prompt 'A name was submitted: abc' do
452
449
  session.click_button('Submit')
453
450
  end
451
+
454
452
  session.fill_in('Name:', with: '')
455
453
  session.accept_prompt(/A name was submitted: $/) do
456
454
  session.click_button('Submit')
457
455
  end
458
- # end
456
+ end
457
+
458
+ it 'works with rapid fill' do
459
+ skip "This test doesn't support older browsers" if ie?(session)
460
+
461
+ session.visit 'react'
462
+ long_string = (0...60).map { |i| ((i % 26) + 65).chr }.join
463
+
464
+ session.fill_in('Name:', with: long_string)
465
+ session.accept_prompt "A name was submitted: #{long_string}" do
466
+ session.click_button('Submit')
467
+ end
459
468
  end
460
469
  end
461
470
  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: 3.32.0
4
+ version: 3.32.1
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: 2020-03-30 00:00:00.000000000 Z
13
+ date: 2020-04-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable