← Back to library
Playwrightformsintermediatev1.38+
Type into a contenteditable div
Interact with rich-text editors and contenteditable elements using pressSequentially().
1test('types into a rich-text editor', async ({ page }) => {
2 await page.goto('/editor');
3
4 const editor = page.locator('[contenteditable="true"]');
5
6 // .fill() does not work on contenteditable elements — use click + pressSequentially
7 await editor.click();
8 await editor.pressSequentially('Hello, Playwright!');
9
10 // To replace existing content: select all then type the replacement
11 await editor.press('Control+a');
12 await editor.pressSequentially('Replaced content');
13
14 await expect(editor).toHaveText('Replaced content');
15});#contenteditable#rich text#editor#pressSequentially