Search code examples
testingautomationautomated-testse2e-testingtestcafe

Testcafe TypeText function not working with CKeditor


I have targeted the following element to enter text into the wysiwyg editor:

<div class="ck ck-content ck-editor__editable ck-rounded-corners ck-editor__editable_inline ck-blurred" lang="en" dir="ltr" role="textbox" aria-label="Editor editing area: main" contenteditable="true"><p><br data-cke-filler="true"></p></div>

For some reason it seems that the typeText function does not want to enter text in the text box

After trying the following. I can see testcafe is clicking into the textbox but not typing any characters:

const editable = Selector('.ckeditor__editable[contenteditable=true')
await t.click(editable).typeText(editable, 'test')

Solution

  • For anyone that comes across the issue there is a bug raised here

    Meanwhile the current work around as stated in the issue that worked for me is as follows:

    await t.eval(() => {
       const editor = window.document.querySelector(".ck-editor__editable");
       editor.ckeditorInstance.data.set(whateverYouWant);
    },
    { 
       dependencies: { whateverYouWant } 
    });