mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(keyboard): support simple copy-pasting using meta+c/v (#10828)
It's a straightforward change to support new, common, keyboard commands
Note that I've tested this locally with Chrome on my Mac but it seems that CI doesn't want to pass Chrome tests - it's running on ubuntu though. Does this mean that I should introduce per-platform editing commands? At the moment there is only a single [`macEditingCommands`](0ed33522c5/packages/playwright-core/src/server/macEditingCommands.ts) file.
References https://github.com/microsoft/playwright/issues/12000
Co-authored-by: Andrey Lushnikov <aslushnikov@gmail.com>
This commit is contained in:
parent
f47423d315
commit
eaa98ce53a
@ -126,4 +126,6 @@ export const macEditingCommands: {[key: string]: string|string[]} = {
|
||||
'Shift+Meta+ArrowRight': 'moveToRightEndOfLineAndModifySelection:',
|
||||
|
||||
'Meta+KeyA': 'selectAll:',
|
||||
'Meta+KeyC': 'copy:',
|
||||
'Meta+KeyV': 'paste:',
|
||||
};
|
||||
|
||||
@ -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 = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user