【发布时间】:2020-05-25 23:29:27
【问题描述】:
我已经从另一个 SO 回答 How to type using cypress .type() inside the codemirror editor? 尝试过类似的事情
如果有帮助,这是我正在使用 https://testing-playground.com/ 在 Cypress 上工作的网站
// CodeMirror's editor doesn't let us clear it from the
// textarea, but we can read the Window object and then
// invoke `setValue` on the editor global
cy.window().then(win => {
win.editor.setValue("")
})
我遇到的问题是,当我尝试实现此功能时,我得到了编辑器的undefined。我尝试深入研究 Window 对象,但找不到任何类似于 Codemirror 编辑器的东西。在任何其他 Codemirror 元素上运行 .clear({force: true}) 不会产生任何结果,只是在文本字段上使用 .type({force: true}) 添加旧内容。
【问题讨论】:
标签: javascript cypress e2e-testing codemirror