* Read the contents of the clipboard. To do this, create a new browser tab with * an element, simulate hitting Control+V to paste into the , and * read what it pasted. * * Playwright can't yet read or paste from the clipboard, so this is a workaround. * https://github.com/microso
(page)
| 9 | * https://github.com/microsoft/playwright/issues/15860 |
| 10 | */ |
| 11 | async function readClipboardContents(page) { |
| 12 | // Create a new browser tab so that none of the event handlers in the |
| 13 | // tab-under-test prevent the test from pasting the clipboard contents. |
| 14 | const freshPage = await page.context().newPage(); |
| 15 | |
| 16 | // Create an input element so the test has a place to paste the clipboard |
| 17 | // contents into. |
| 18 | const input = await freshPage.evaluateHandle(() => { |
| 19 | return document.body.appendChild(document.createElement("input")); |
| 20 | }); |
| 21 | |
| 22 | const isMac = process.platform === "darwin"; |
| 23 | const modifier = isMac ? "Meta" : "Control"; |
| 24 | await input.press(`${modifier}+KeyV`); |
| 25 | |
| 26 | return await input.inputValue(); |
| 27 | } |
| 28 | |
| 29 | test.describe("debug logs dialog", () => { |
| 30 | test.beforeEach(async ({ page }) => { |