Reputation: 294
I am testing a webapp with nightwatchjs. I need to be able to set the content of a tinyMCE container. I have tried the simple .setContent for a tinyMCE object but it throws a reference error saying tinyMCE is not defined.
Upvotes: 0
Views: 564
Reputation: 569
I've had no problems using the native TinyMCE API with execute:
.execute(function(){
tinyMCE.activeEditor.setContent('<p>Some text</p>')
})
or for something more generic, say a page object command:
commands: [{
setBody: function(bodytext){
return this.api.execute(function(text){
tinyMCE.activeEditor.setContent('<p>'+text+'</p>')
}, [bodytext])
}
}]
Upvotes: 0
Reputation: 294
I managed to use the execute() command to get to the tinyMCE frame and just set the innerHTML of the tinyMCE to what i wanted
.execute('var x = document.getElementById("Body1_ifr"); var y = (x.contentWindow || x.contentDocument); if (y.document)y = y.document; y.body.innerHTML = "Article body";')
Upvotes: 1