In a django project I've loaded a ckeditor in this way
CKEDITOR.replace('id_content', {
toolbar: 'Basic',
readOnly: {{ editing|yesno:"false,true" }}
});
and in my casperjs script I tried to access the editor in this way
var ckeditor = this.evaluate(function () {
return document.querySelector('#id_content').contentWindow.CKEDITOR;
});
ckeditor.instances.id_content.setData( '<p>AAA bbb CCC</p>' );
based on what I read in this post access-javascript-ckeditor-object-within-an-iframe but console output is the following
FAIL TypeError: 'null' is not an object (evaluating 'ckeditor.instances')
Any idea? Thanks!
Edit:
If I try to do all stuff in evaluate method the ckeditor content not changes. The following code
var ckeditor = this.evaluate(function () {
var ckeditor = document.querySelector('#id_content').contentWindow.CKEDITOR;
ckeditor.instances.id_content.setData('<p>AAA bbb CCC </p>');
});
this.test.assertField('content', '<p>AAA bbb CCC</p>');
fails an output
FAIL "content" input field has the value "<p>AAA bbb CCC</p>"
# type: assertField
# code: this.test.assertField('content', '<p>AAA bbb CCC</p>');
# subject: false
# inputName: "content"
# actual: "<p>In et qui nobis eos. Rem impedit ullam nihil placeat in. Et ea explicabo earum quam. Earum rerum ipsum ea soluta.</p>\n"
# expected: "<p>AAA bbb CCC</p>"