首页 > 解决方案 > 无法使用 Cypress 在 CK 编辑器中输入数据

问题描述

下面的解决方案一直工作到 chrome 版本 70,现在 70+ 我收到错误 CypressError: Timed out retrying: Expected to find element: 'p:eq(0)', but never found it. Queried from element: <body.cke_editable.cke_editable_themed.cke_contents_ltr>

现在停止工作的解决方案:


.then(function ($iframe) {
 const $body = $iframe.contents().find('body')
    cy
    .wrap($body)
    .find('p:eq(0)').type( "test", { force: true })
})

标签: automationcypress

解决方案


您使用的是哪个版本的 CKEditor,您使用的是 javascript 框架吗?我们使用此命令在 Angular 应用程序中将文本输入到 CKEditor 实例中并获得预期结果:

cy.get('parent-element')
.find('[contenteditable=true]')
.type('text')

也许它有帮助。


推荐阅读