Search code examples
laravelseleniumlaravel-dusklaravel-testing

How can I edit divs with 'contenteditable' property with Laravel Dusk?


I have a wysiwyg editor in my project, that I need to test and it has a contenteditable property. I cant type directly, as it is a simple <trix-editor> tag:

<trix-editor input="28" placeholder="Type your message here..." contenteditable="" role="textbox" trix-id="2" toolbar="trix-toolbar-2">
</trix-editor>

As you can notice, it has contenteditable attribute. I can edit it easily with Selenium IDE when running Selenium tests and it shows command edit content.

Can the same be done with Laravel Dusk?


Solution

  • You can edit the content with keys():

    $browser->keys('[trix-id="2"]', 'Text')