Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy-paste using Capybara?

I would love to do something like this:

div = find '#some-div'
copy_to_clipboard(div)

input = find '#my-input'
paste_from_clipboard(input)

I do not want to simulate this with send_keys and using Ctrl+C and Ctrl+V; I want this to work cross-browser (especially on mobile).

Does this API exist?

like image 257
Evan Hahn Avatar asked Jul 18 '26 15:07

Evan Hahn


1 Answers

The most simple way I've found:

element.send_keys [:control, 'c']
element.send_keys [:control, 'v']
like image 198
Cleber Oliveira Avatar answered Jul 21 '26 04:07

Cleber Oliveira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!