I have a textarea which is using Summernote and I set onChange event to it. I want to write test with RSpec + Capybara + Poltergeist to confirm the onChange event is working
After updating Summernote to 0.8.2, find('div[contenteditable]').set('This is awesome blog.')
does not work.
I had to call Summernote API via execute_script
like:
script = <<-JS
$('.some-field').summernote('editor.insertText', 'This is awesome blog.');
JS
execute_script(script)
After updating Summernote to 0.8.2,
find('div[contenteditable]').set('This is awesome blog.')
does not work.
Sorry, this was not what I wanted to say. I should have said like this:
After updating Summernote to 0.8.2, find('div[contenteditable]').set('This is awesome blog.')
does not fire Summernotes's onChange callback. So I had to call execute_script
.
I have to test onChange behavior in my specs.
As Thomas Walpole wrote, send_keys
method could be used instead of execute_script
. Thanks Thomas Walpole!
find('div[contenteditable]').send_keys('This is awesome blog.')
Capybaras fill_in only works with html form elements. Since the JS version of your page is using a DIV with the contenteditable attribute as its text area to be filled #fill_in will not work. Instead you need to find the div and call #set on it directly. In your project the following should work
find('div[contenteditable]').set('This is awesome blog.')