Skip to content

Commit

Permalink
Fix emoji sending in headless chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Oct 11, 2020
1 parent a4be186 commit a76e4a8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/capybara/selenium/nodes/chrome_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ def send_keys(*args)
.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
.each do |_emoji, clusters|
# For non-headless we can send non-emoji normally and then send emoji via CDP
# thereby getting key events and emoji. Unfortunately that doesn't work for
# headless chrome currently so just send via cdp
driver.send(:execute_cdp, 'Input.insertText', text: clusters.join)

# .each do |emoji, clusters|
# if emoji
# driver.send(:execute_cdp, 'Input.insertText', text: clusters.join)
# else
# super(clusters.join)
# end
end
else
super(*inputs)
Expand Down

0 comments on commit a76e4a8

Please sign in to comment.