0 votes
1 view
in Devops and Agile by (19.8k points)

How can I fill a CKEditor area within Capybara, assuming I'm using a javascript capable driver like capybara-webkit or selenium?

1 Answer

0 votes
by (63.4k points)

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});

  SCRIPT

end

 

# Example:

fill_in_ckeditor 'email_body', :with => 'some message!'

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...