Shol Shol - 28 days ago 20
AngularJS Question

How can I set data to field with CKEditor in Protractor test?

My issue is that I got message, "element not visible" in protractor when I tried to set data into field with CKEditor.
Application is working with AngularJS.

element(by.model("question.translations[lang.locale].answer")).sendKeys("Test answer e2e!!!");


How can I set (or get) data to field with CKEditor in Protractor test?
HTML code:



<div ng-repeat="lang in languages">
<div class="col-md-4">
<div class="input-icon right">
<div ckeditor="CKoptions" ng-model="question.translations[lang.locale].answer"></div>
</div>
</div>
</div>





When I try this



var value = 'Hello';
browser.executeScript(function (arguments) {
window.CKEDITOR.instances.html_editor.setData(arguments[0]);
}, value);





I get the error: Failed: unknown error: Cannot read property 'setData' of undefined

Answer

I found a solution

browser.switchTo().frame(element(by.css('#cke_editor1 iframe')).click().sendKeys("Test answer e2e"));