test: add a test for android screenshots (#26377)

References #26342.
This commit is contained in:
Dmitry Gozman 2023-08-09 10:40:33 -07:00 committed by GitHub
parent 732ee1502c
commit 71bcfac28a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 0 deletions

View File

@ -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();

View File

@ -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,
});