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.
Asked
Active
Viewed 540 times
2 Answers
1
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";')

BrandenB171
- 294
- 4
- 20
-
I came across this same problem, thanks for coming back and posting your solution. It helped. – lasec0203 Dec 31 '17 at 06:04
0
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])
}
}]

Dan Caseley
- 521
- 6
- 8