mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Support filling in with Emoji using Chrome browser
This commit is contained in:
parent
919b6fcb7a
commit
c534325304
2 changed files with 26 additions and 0 deletions
|
@ -73,6 +73,24 @@ class Capybara::Selenium::ChromeNode < Capybara::Selenium::Node
|
|||
end
|
||||
end
|
||||
|
||||
def send_keys(*args)
|
||||
args.chunk { |inp| inp.is_a?(String) && inp.match?(/\p{Emoji Presentation}/) }
|
||||
.each do |contains_emoji, inputs|
|
||||
if contains_emoji
|
||||
inputs.join.grapheme_clusters.chunk { |gc| gc.match?(/\p{Emoji Presentation}/) }
|
||||
.each do |emoji, clusters|
|
||||
if emoji
|
||||
driver.send(:execute_cdp, 'Input.insertText', text: clusters.join)
|
||||
else
|
||||
super(clusters.join)
|
||||
end
|
||||
end
|
||||
else
|
||||
super(*inputs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def perform_legacy_drag(element, drop_modifiers)
|
||||
|
|
|
@ -214,6 +214,14 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|||
end
|
||||
end
|
||||
|
||||
describe '#fill_in with Emoji' do
|
||||
it 'sends emojis' do
|
||||
session.visit('/form')
|
||||
session.fill_in('form_first_name', with: 'a😀cd😴 🛌🏽🇵🇹 e🤾🏽♀️f')
|
||||
expect(session.find(:fillable_field, 'form_first_name').value).to eq('a😀cd😴 🛌🏽🇵🇹 e🤾🏽♀️f')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#path' do
|
||||
it 'returns xpath' do
|
||||
# this is here because it is testing for an XPath that is specific to the algorithm used in the selenium driver
|
||||
|
|
Loading…
Reference in a new issue