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 cut-pasting using meta+x/v (#18756)
Zihua Li0c6a0f40c668
diff --git a/packages/playwright-core/src/server/macEditingCommands.ts b/packages/playwright-core/src/server/macEditingCommands.tsindex c6de45d462..38634c0a2e 100644--- a/packages/playwright-core/src/server/macEditingCommands.ts+++ b/packages/playwright-core/src/server/macEditingCommands.ts@@ -127,6 +127,7 @@ export const macEditingCommands: {[key: string]: string|string[]} = {'Meta+KeyA': 'selectAll:','Meta+KeyC': 'copy:',+ 'Meta+KeyX': 'cut:','Meta+KeyV': 'paste:','Meta+KeyZ': 'undo:','Shift+Meta+KeyZ': 'redo:',diff --git a/tests/page/page-keyboard.spec.ts b/tests/page/page-keyboard.spec.tsindex 879dc93718..3338fdfeb3 100644--- a/tests/page/page-keyboard.spec.ts+++ b/tests/page/page-keyboard.spec.ts@@ -482,6 +482,17 @@ it('should support simple copy-pasting', async ({ page, isMac, browserName }) =>expect(await page.evaluate(() => document.querySelector('div').textContent)).toBe('123123');});+it('should support simple cut-pasting', async ({ page, isMac }) => {+ 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}+KeyX`);+ await page.keyboard.press(`${modifier}+KeyV`);+ await page.keyboard.press(`${modifier}+KeyV`);+ expect(await page.evaluate(() => document.querySelector('div').textContent)).toBe('123123');+});+it('should support undo-redo', async ({ page, isMac, browserName, isLinux }) => {it.fixme(browserName === 'webkit' && isLinux, 'https://github.com/microsoft/playwright/issues/12000');const modifier = isMac ? 'Meta' : 'Control';