1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Merge pull request #2361 from teamcapybara/pr/2359

Minor extension to PR #2359
This commit is contained in:
Thomas Walpole 2020-05-30 14:02:00 -07:00 committed by GitHub
commit 3842679ecf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -281,7 +281,7 @@ private
driver.execute_script 'arguments[0].select()', self unless clear == :none
if rapid == true || ((value.length > auto_rapid_set_length) && rapid != false)
send_keys(value[0..3])
driver.execute_script RAPID_SET_TEXT, self, value[0...-3]
driver.execute_script RAPID_APPEND_TEXT, self, value[4...-3]
send_keys(value[-3..-1])
else
send_keys(value)
@ -534,8 +534,9 @@ private
})(arguments[0], arguments[1], arguments[2])
JS
RAPID_SET_TEXT = <<~'JS'
RAPID_APPEND_TEXT = <<~'JS'
(function(el, value) {
value = el.value + value;
if (el.maxLength && el.maxLength != -1){
value = value.slice(0, el.maxLength);
}

View file

@ -160,6 +160,15 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
fill_options: { clear: :none })
expect(session.find(:fillable_field, 'form_first_name').value).to eq('JohnHarry')
end
it 'works with rapid fill' do
pending 'Safari overwrites by default - need to figure out a workaround' if safari?(session)
long_string = (0...60).map { |i| ((i % 26) + 65).chr }.join
session.visit('/form')
session.fill_in('form_first_name', with: long_string, fill_options: { clear: :none })
expect(session.find(:fillable_field, 'form_first_name').value).to eq('John' + long_string)
end
end
describe '#fill_in with Date' do