gpt4 book ai didi

javascript - CKEditor + Protractor : Testing with Protractor can't find CKEditor instance

转载 作者:行者123 更新时间:2023-11-30 00:29:10 25 4
gpt4 key购买 nike

我正在为非 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);

关于javascript - CKEditor + Protractor : Testing with Protractor can't find CKEditor instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30252840/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com