Back
How can I fill a CKEditor area within Capybara, assuming I'm using a javascript capable driver like capybara-webkit or selenium?
Here's a solution in which by using javascript both to set the data on the hidden textarea and on the CKEditor object.
def fill_in_ckeditor(locator, opts) content = opts.fetch(:with).to_json # convert to a safe javascript string page.execute_script <<-SCRIPT CKEDITOR.instances['#{locator}'].setData(#{content}); $('textarea##{locator}').text(#{content}); SCRIPTend # Example:fill_in_ckeditor 'email_body', :with => 'some message!'
def fill_in_ckeditor(locator, opts)
content = opts.fetch(:with).to_json # convert to a safe javascript string
page.execute_script <<-SCRIPT
CKEDITOR.instances['#{locator}'].setData(#{content});
$('textarea##{locator}').text(#{content});
SCRIPT
end
# Example:
fill_in_ckeditor 'email_body', :with => 'some message!'
31k questions
32.8k answers
501 comments
693 users