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
chore: page.screenshot() in bidi (#32671)
Yury Semikhatsky4c4d74ca5b98
diff --git a/packages/playwright-core/src/server/bidi/bidiPage.ts b/packages/playwright-core/src/server/bidi/bidiPage.tsindex 2f2e09441f..180e8a651e 100644--- a/packages/playwright-core/src/server/bidi/bidiPage.ts+++ b/packages/playwright-core/src/server/bidi/bidiPage.ts@@ -404,7 +404,20 @@ export class BidiPage implements PageDelegate {}async takeScreenshot(progress: Progress, format: string, documentRect: types.Rect | undefined, viewportRect: types.Rect | undefined, quality: number | undefined, fitsViewport: boolean, scale: 'css' | 'device'): Promise<Buffer> {- throw new Error('Method not implemented.');+ const rect = (documentRect || viewportRect)!;+ const { data } = await this._session.send('browsingContext.captureScreenshot', {+ context: this._session.sessionId,+ format: {+ type: `image/${format === 'png' ? 'png' : 'jpeg'}`,+ quality: quality || 80,+ },+ origin: documentRect ? 'document' : 'viewport',+ clip: {+ type: 'box',+ ...rect,+ }+ });+ return Buffer.from(data, 'base64');}async getContentFrame(handle: dom.ElementHandle): Promise<frames.Frame | null> {diff --git a/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-bounding-box-bidi-chromium.png b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-bounding-box-bidi-chromium.pngnew file mode 100644index 0000000000..c2c3ddca29Binary files /dev/null and b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-bounding-box-bidi-chromium.png differdiff --git a/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-fractional-bidi-chromium.png b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-fractional-bidi-chromium.pngnew file mode 100644index 0000000000..35c53377f9Binary files /dev/null and b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-fractional-bidi-chromium.png differdiff --git a/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-fractional-offset-bidi-chromium.png b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-fractional-offset-bidi-chromium.pngnew file mode 100644index 0000000000..971561ba69Binary files /dev/null and b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-fractional-offset-bidi-chromium.png differdiff --git a/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-larger-than-viewport-bidi-chromium.png b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-larger-than-viewport-bidi-chromium.pngnew file mode 100644index 0000000000..52c1bb2b92Binary files /dev/null and b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-larger-than-viewport-bidi-chromium.png differdiff --git a/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-padding-border-bidi-chromium.png b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-padding-border-bidi-chromium.pngnew file mode 100644index 0000000000..fc34319896Binary files /dev/null and b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-padding-border-bidi-chromium.png differdiff --git a/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-rotate-bidi-chromium.png b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-rotate-bidi-chromium.pngnew file mode 100644index 0000000000..5aab14c4b9Binary files /dev/null and b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-rotate-bidi-chromium.png differdiff --git a/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-scrolled-into-view-bidi-chromium.png b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-scrolled-into-view-bidi-chromium.pngnew file mode 100644index 0000000000..fc34319896Binary files /dev/null and b/tests/page/elementhandle-screenshot.spec.ts-snapshots/screenshot-element-scrolled-into-view-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/canvas-changes-0-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/canvas-changes-0-bidi-chromium.pngnew file mode 100644index 0000000000..6fcce2cf53Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/canvas-changes-0-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/canvas-changes-1-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/canvas-changes-1-bidi-chromium.pngnew file mode 100644index 0000000000..f6f130a44aBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/canvas-changes-1-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/canvas-changes-2-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/canvas-changes-2-bidi-chromium.pngnew file mode 100644index 0000000000..ecabd8b22dBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/canvas-changes-2-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/grid-cell-1-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/grid-cell-1-bidi-chromium.pngnew file mode 100644index 0000000000..2eab11668dBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/grid-cell-1-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/hide-should-work-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/hide-should-work-bidi-chromium.pngnew file mode 100644index 0000000000..dd0549a411Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/hide-should-work-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/mask-color-should-work-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/mask-color-should-work-bidi-chromium.pngnew file mode 100644index 0000000000..fef9e17ffeBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/mask-color-should-work-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/mask-should-work-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/mask-should-work-bidi-chromium.pngnew file mode 100644index 0000000000..c663e342dcBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/mask-should-work-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/mask-should-work-with-elementhandle-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/mask-should-work-with-elementhandle-bidi-chromium.pngnew file mode 100644index 0000000000..5a13aac48bBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/mask-should-work-with-elementhandle-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/mask-should-work-with-locator-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/mask-should-work-with-locator-bidi-chromium.pngnew file mode 100644index 0000000000..5a13aac48bBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/mask-should-work-with-locator-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/page-screenshot-should-capture-css-transform-1-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/page-screenshot-should-capture-css-transform-1-bidi-chromium.pngnew file mode 100644index 0000000000..d29a2b4ab2Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/page-screenshot-should-capture-css-transform-1-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/remove-should-work-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/remove-should-work-bidi-chromium.pngnew file mode 100644index 0000000000..d35ddd4289Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/remove-should-work-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-bidi-chromium.pngnew file mode 100644index 0000000000..dfafbda638Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-bidi-chromium.pngnew file mode 100644index 0000000000..0971000b5fBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-text-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-clip-odd-size-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-clip-odd-size-bidi-chromium.pngnew file mode 100644index 0000000000..61c0b7044aBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-clip-odd-size-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-clip-rect-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-clip-rect-bidi-chromium.pngnew file mode 100644index 0000000000..8c4046910bBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-clip-rect-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-grid-fullpage-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-grid-fullpage-bidi-chromium.pngnew file mode 100644index 0000000000..0354694da1Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-grid-fullpage-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-grid-fullpage-mask-outside-viewport-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-grid-fullpage-mask-outside-viewport-bidi-chromium.pngnew file mode 100644index 0000000000..9e97bfcedbBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-grid-fullpage-mask-outside-viewport-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-iframe-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-iframe-bidi-chromium.pngnew file mode 100644index 0000000000..56aa8706bbBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-iframe-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-offscreen-clip-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-offscreen-clip-bidi-chromium.pngnew file mode 100644index 0000000000..21f7b0f461Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-offscreen-clip-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-sanity-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-sanity-bidi-chromium.pngnew file mode 100644index 0000000000..122a4f0ae0Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-sanity-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-translateZ-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-translateZ-bidi-chromium.pngnew file mode 100644index 0000000000..e3f5642e60Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-translateZ-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-web-font-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-web-font-bidi-chromium.pngnew file mode 100644index 0000000000..40aa6d483cBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-web-font-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-webgl-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-webgl-bidi-chromium.pngnew file mode 100644index 0000000000..76109512b5Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-webgl-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/should-capture-css-box-shadow-1-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/should-capture-css-box-shadow-1-bidi-chromium.pngnew file mode 100644index 0000000000..089549eb3cBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/should-capture-css-box-shadow-1-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/should-mask-in-parallel-1-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/should-mask-in-parallel-1-bidi-chromium.pngnew file mode 100644index 0000000000..18f4ed1e60Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/should-mask-in-parallel-1-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/should-mask-in-parallel-2-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/should-mask-in-parallel-2-bidi-chromium.pngnew file mode 100644index 0000000000..bf3dbe65bdBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/should-mask-in-parallel-2-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/should-mask-inside-iframe-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/should-mask-inside-iframe-bidi-chromium.pngnew file mode 100644index 0000000000..c663e342dcBinary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/should-mask-inside-iframe-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/should-mask-multiple-elements-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/should-mask-multiple-elements-bidi-chromium.pngnew file mode 100644index 0000000000..0ff0cf5137Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/should-mask-multiple-elements-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/transparent-bidi-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/transparent-bidi-chromium.pngnew file mode 100644index 0000000000..b9aa8f7a72Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/transparent-bidi-chromium.png differdiff --git a/tests/page/page-screenshot.spec.ts-snapshots/white-bidi-chromium.jpg b/tests/page/page-screenshot.spec.ts-snapshots/white-bidi-chromium.jpgnew file mode 100644index 0000000000..ed816ce766Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/white-bidi-chromium.jpg differ