CKEditor + Protractor:用 Protractor 测试找不到 CKEditor 实例
CKEditor + Protractor: Testing with Protractor can't find CKEditor instance
我正在为非 Angular 页面使用 Protractor,并希望在该页面上找到 CKEditor 实例,然后为其设置数据。我可以通过以下方式在 Chrome 控制台中执行此操作:
CKEDITOR.instances.html_editor.setData("Hello")
在我的页面测试中,我有以下代码:
it('should enter text in editor successfully', function() {
var composerPage = new ComposerPage();
browser.executeScript('return window.CKEDITOR');
window.CKEDITOR.instances.html_editor.setData( 'Hello' );
});
但是,返回的错误是:
Error: Failed: Cannot read property 'instances' of undefined
我已经在这里查看了这个 Stack Overflow 问题:Protractor: How to access global variables that we have inside our application? 但并没有真正帮助我摆脱困境。
关于如何定义 CKEditor 实例和设置数据的任何建议都会有所帮助!
使用browser.executeScript()
设置编辑器的数据:
var value = 'Hello';
browser.executeScript(function (arguments) {
window.CKEDITOR.instances.html_editor.setData(arguments[0]);
}, value);
我正在为非 Angular 页面使用 Protractor,并希望在该页面上找到 CKEditor 实例,然后为其设置数据。我可以通过以下方式在 Chrome 控制台中执行此操作:
CKEDITOR.instances.html_editor.setData("Hello")
在我的页面测试中,我有以下代码:
it('should enter text in editor successfully', function() {
var composerPage = new ComposerPage();
browser.executeScript('return window.CKEDITOR');
window.CKEDITOR.instances.html_editor.setData( 'Hello' );
});
但是,返回的错误是:
Error: Failed: Cannot read property 'instances' of undefined
我已经在这里查看了这个 Stack Overflow 问题:Protractor: How to access global variables that we have inside our application? 但并没有真正帮助我摆脱困境。
关于如何定义 CKEditor 实例和设置数据的任何建议都会有所帮助!
使用browser.executeScript()
设置编辑器的数据:
var value = 'Hello';
browser.executeScript(function (arguments) {
window.CKEDITOR.instances.html_editor.setData(arguments[0]);
}, value);