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
feat(keyboard): support simple copy-pasting using meta+c/v (#10828)
Mateusz Burzyńskieaa98ce53a73
diff --git a/packages/playwright-core/src/server/macEditingCommands.ts b/packages/playwright-core/src/server/macEditingCommands.tsindex d7867da029..8f4c496e8a 100644--- a/packages/playwright-core/src/server/macEditingCommands.ts+++ b/packages/playwright-core/src/server/macEditingCommands.ts@@ -126,4 +126,6 @@ export const macEditingCommands: {[key: string]: string|string[]} = {'Shift+Meta+ArrowRight': 'moveToRightEndOfLineAndModifySelection:','Meta+KeyA': 'selectAll:',+ 'Meta+KeyC': 'copy:',+ 'Meta+KeyV': 'paste:',};diff --git a/tests/page/page-keyboard.spec.ts b/tests/page/page-keyboard.spec.tsindex ed31edb50e..29638647dc 100644--- a/tests/page/page-keyboard.spec.ts+++ b/tests/page/page-keyboard.spec.ts@@ -464,6 +464,18 @@ it('should dispatch a click event on a button when Enter gets pressed', async ({expect((await actual.jsonValue()).clicked).toBe(true);});+it('should support simple copy-pasting', async ({ page, isMac, browserName }) => {+ it.fixme(browserName === 'webkit', 'https://github.com/microsoft/playwright/issues/12000');+ const modifier = isMac ? 'Meta' : 'Control';+ await page.setContent(`<div contenteditable>123</div>`);+ await page.focus('div');+ await page.keyboard.press(`${modifier}+KeyA`);+ await page.keyboard.press(`${modifier}+KeyC`);+ await page.keyboard.press(`${modifier}+KeyV`);+ await page.keyboard.press(`${modifier}+KeyV`);+ expect(await page.evaluate(() => document.querySelector('div').textContent)).toBe('123123');+});+async function captureLastKeydown(page) {const lastEvent = await page.evaluateHandle(() => {const lastEvent = {