How can I fill a CKEditor area within Capybara, assuming I'm using a javascript capable driver like capybara-webkit or selenium?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Selecting an item from a combo box selenium driver
- Eager-loading association count with Arel (Rails 3
- Selenium in Java is not finding element when using
A small addition to Marc-André's awesome answer
If you are using nested form or multiple textareas in the same page generated IDs are pretty ugly and hard to write into tests (e.g.
person_translations_attributes_2_biography
) with this small addition to his method you can locate ckeditors using their labels instead of IDIn this way instead of this
you can write this
For me Marc-André's answer switches iframe context in webkit driver. See this capybara-webkit issue
I found another way to fill in ckeditor input which doesn't change iframe context:
and call it
fill_in_ckeditor 'comment', with: 'This is my message!'
Works both with webkit and selenium drivers
Inspired by this post
RSpec + Capybara support file to work with ckeditor instances
https://gist.github.com/3308129
Inspired from what I found here, I came up with the solution of using javascript to both set the data on the hidden
textarea
and on theCKEditor
object. Neither seemed sufficient, depending on the circumstances.