I have a textarea with the id of “request_details”, made into a CKEditor instance by jQuery: $(‘#request_details’).ckeditor();
(Check this page if you need some help getting CKEditor to work with jQuery, it’s dead simple)
Feature looks like this: And I fill in "Here are some details" in the CKEditor instance "request_details"
Step looks like this:
When /^I fill in "([^"]*)" in the CKEditor instance "([^"]*)"$/ do |value, input_id|
browser = page.driver.browser
browser.execute_script("CKEDITOR.instances['#{input_id}'].setData('#{value}');")
end
[...] Trice shows how to test CKEditor in your [...]
I’ll try to put this to good use immdieaetly.
worked a treat for me once I set Capybara to use :selenium driver rather than :webkit, thanks!
Worked for me. Thanks!
Most helpful, thanks.
To be complete, it’s probably best to replace the ‘#{value}’ with #{value.to_json}, as this will escape quotes and thus avoid potential javascript errors.
@Michael: Works perfectly for me with capybara-webkit
Strangely enough, it didn’t work anymore with webkit, even though the script executed correctly and getData() returned the correct string. I came up with an extended solution, see http://stackoverflow.com/questions/10957869/how-to-fill-ckeditor-from-capybara-with-webkit-or-selenium-driver
browser.execute_script(“CKEDITOR.instances.SELECTOR.setData(‘test’)”)