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
test: add a test for android screenshots (#26377)
Dmitry Gozman71bcfac28a4a
diff --git a/tests/android/browser.spec.ts b/tests/android/browser.spec.tsindex 54d4dc57a0..2590ef791b 100644--- a/tests/android/browser.spec.ts+++ b/tests/android/browser.spec.ts@@ -86,6 +86,44 @@ test('should check', async function({ androidDevice }) {await context.close();});+test('should take page screenshot', async function({ androidDevice }) {+ test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/26342' });+ test.fixme(true, 'Sometimes fails with Protocol error (Page.captureScreenshot): Unable to capture screenshot');+ test.fixme(true, 'Regular screenshot has an extra pixel border');+ test.fixme(true, 'Full page screenshot has repeated content');++ const context = await androidDevice.launchBrowser();+ const [page] = context.pages();++ await page.setContent(`+ <html lang="en">+ <head>+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ </head>+ <body>+ <style>+ * { margin: 0; padding: 0; }+ div {+ width: 200px;+ height: 250px;+ }+ </style>+ <div style="background: red"></div>+ <div style="background: green"></div>+ <div style="background: red"></div>+ <div style="background: green"></div>+ <div style="background: red"></div>+ <div style="background: green"></div>+ </body>+ </html>+ `);+ const screenshot = await page.screenshot({ fullPage: false, scale: 'css' });+ const fullPageScreenshot = await page.screenshot({ fullPage: true, scale: 'css' });+ expect(screenshot).toMatchSnapshot('page-screenshot.png');+ expect(fullPageScreenshot).toMatchSnapshot('fullpage-screenshot.png');+ await context.close();+});+test('should be able to send CDP messages', async ({ androidDevice }) => {const context = await androidDevice.launchBrowser();const [page] = context.pages();diff --git a/tests/android/playwright.config.ts b/tests/android/playwright.config.tsindex 827115b188..1422f1511d 100644--- a/tests/android/playwright.config.ts+++ b/tests/android/playwright.config.ts@@ -55,6 +55,7 @@ config.projects.push({loopback: '10.0.2.2',browserName: 'chromium',},+ snapshotPathTemplate: '{testDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}{ext}',testDir: path.join(testDir, 'android'),metadata,});@@ -65,6 +66,7 @@ config.projects.push({loopback: '10.0.2.2',browserName: 'chromium',},+ snapshotPathTemplate: '{testDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}{ext}',testDir: path.join(testDir, 'page'),metadata,});