如何解决如何使用testcafe在monaco编辑器上删除或替换文本?
我正在用testcafe编写一些测试。 我有一些文本的monaco编辑器字段,我想删除该文本并插入另一个文本,或者只是覆盖我拥有的文本。 我尝试了这段代码,并在第一行的字符之后插入了“ someText”。 我使用了以下代码:
autoGroupColumnDef: {
width: 180,cellStyle: function(params) {
//check that the autogroup is built using country column and then color every odd cell
if(params.node.field ==='country' && params.node.rowIndex% 2 === 1){
return {color: 'red','background-color': 'white'}
}
}
},
有什么主意吗?
摩纳哥之前:
await t.typeText(Selector('.parent-class .inputarea'),someText);
摩纳哥之后:
{
"data": {
"a": 1,"b": 2,"c": 3
}
}
解决方法
您可以使用replace
选项覆盖现有文本:
await t.typeText(Selector('.parent-class .inputarea'),someText,{ replace: true });
有关更多信息,请参见the typeText method。
,我尝试与Monaco Editor Playground中的文本进行交互,事实证明这确实具有挑战性。
您可以通过.pressKey('ctrl+a')
选择该字段的内容,然后使用.typeText()
键入新内容来覆盖该字段的内容。
fixture `monaco`
.page `https://microsoft.github.io/monaco-editor/playground.html`;
test('Monaco Ctrl+A',async t => {
await t
.switchToIframe(Selector('#runner'))
.click(Selector('#container').find('.inputarea'))
.pressKey('ctrl+a')
.typeText(Selector('#container').find('.inputarea'),'typetext');
});
您可以使用其他page actions获得类似的结果。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。