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 04ee9ce
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/capybara/selenium/nodes/chrome_node.rb
Expand Up @@ -79,11 +79,16 @@ def send_keys(*args)
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
# 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)

# 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 04ee9ce

Please sign in to comment.