Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test(keyboard): add test with contenteditable and selection (#5938)
Joel Einbinder8e6639b77039
diff --git a/tests/page-keyboard.spec.ts b/tests/page-keyboard.spec.tsindex 670eee498f..612e314340 100644--- a/tests/page-keyboard.spec.ts+++ b/tests/page-keyboard.spec.ts@@ -420,6 +420,28 @@ it('should scroll with PageDown', async ({page, server}) => {await page.waitForFunction(() => scrollY > 0);});+it('should move around the selection in a contenteditable', async ({page, isMac}) => {+ await page.setContent(`<div contenteditable></div>`);+ await page.focus('div');+ const modifier = isMac ? 'Alt' : 'Control';+ await page.keyboard.type('Hello World');+ await page.keyboard.down(modifier);+ await page.keyboard.down('Shift');+ await page.keyboard.press('ArrowLeft');+ await page.keyboard.up('Shift');+ await page.keyboard.up(modifier);+ expect(await page.evaluate(() => window.getSelection().toString())).toBe('World');+});++it('should move to the start of the document', async ({page, isMac}) => {+ it.skip(!isMac);+ await page.setContent(`<div contenteditable></div>`);+ await page.focus('div');+ await page.keyboard.type('1\n2\n3\n');+ await page.keyboard.press('Shift+Meta+ArrowUp');+ expect(await page.evaluate(() => window.getSelection().toString())).toBe('1\n2\n3\n');+});+async function captureLastKeydown(page) {const lastEvent = await page.evaluateHandle(() => {const lastEvent = {