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
fix(cli): pdf/screenshot did not save artifacts (#21352)
Max Schmitte1e69cbbcc6e
diff --git a/packages/playwright-core/src/cli/cli.ts b/packages/playwright-core/src/cli/cli.tsindex 81d8785b8c..ec167e0588 100755--- a/packages/playwright-core/src/cli/cli.ts+++ b/packages/playwright-core/src/cli/cli.ts@@ -600,13 +600,14 @@ async function waitForPage(page: Page, captureOptions: CaptureOptions) {}async function screenshot(options: Options, captureOptions: CaptureOptions, url: string, path: string) {- const { browser, context } = await launchContext(options, true);+ const { context } = await launchContext(options, true);console.log('Navigating to ' + url);const page = await openPage(context, url);await waitForPage(page, captureOptions);console.log('Capturing screenshot into ' + path);await page.screenshot({ path, fullPage: !!captureOptions.fullPage });- await browser.close();+ // launchContext takes care of closing the browser.+ await page.close();}async function pdf(options: Options, captureOptions: CaptureOptions, url: string, path: string) {@@ -614,13 +615,14 @@ async function pdf(options: Options, captureOptions: CaptureOptions, url: stringconsole.error('PDF creation is only working with Chromium');process.exit(1);}- const { browser, context } = await launchContext({ ...options, browser: 'chromium' }, true);+ const { context } = await launchContext({ ...options, browser: 'chromium' }, true);console.log('Navigating to ' + url);const page = await openPage(context, url);await waitForPage(page, captureOptions);console.log('Saving as pdf into ' + path);await page.pdf!({ path });- await browser.close();+ // launchContext takes care of closing the browser.+ await page.close();}function lookupBrowserType(options: Options): BrowserType {