Comments (6)
@napsta32 Are you using await expect(page).toHaveScreenshot()
assertion? I believe that this assertion defaults to non-retina screenshots. If that's not the case, we would love to see a repro to debug it.
from playwright.
@dgozman I used this to test snapshots and got the "scaled" screenshots in webkit:
import { test, expect } from '@playwright/test';
test('button snapshot', async ({ page }) => {
await page.goto('https://playwright.dev/');
const getStartedButton = page.getByText('Get started');
const screenshot = await getStartedButton.screenshot({
type: 'png'
});
expect(screenshot).toMatchSnapshot();
});
To create the project I used npm init playwright@latest
.
To run the test: npx playwright test --update-snapshots
Snapshots generated:
- Chromium: 177× 52
- Firefox: 178 × 52
- WebKit: 354 × 104
System info:
$ npx envinfo --preset playwright
System:
OS: macOS 14.4.1
CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
Memory: 605.48 MB / 16.00 GB
Binaries:
Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
IDEs:
VSCode: 1.90.1 - /usr/local/bin/code
Languages:
Bash: 5.2.26 - /usr/local/bin/bash
npmPackages:
@playwright/test: ^1.44.1 => 1.44.1
from playwright.
Using toHaveScreenshot
effectively uses a different scale factor:
import { test, expect } from '@playwright/test';
test('button snapshot', async ({ page }) => {
await page.goto('https://playwright.dev/');
const getStartedButton = page.getByText('Get started');
await expect(getStartedButton).toHaveScreenshot();
});
from playwright.
@napsta32 Pass the scale: 'css'
option when taking a screenshot. Or better yet, use toHaveScreenshot()
assertion instead. This way, you'll always get css-scaled screenshots.
from playwright.
Related Issues (20)
- [Docs]: python docs: pressSequentially should be press_sequentially
- [Feature]: undeprecate the dev tools option. HOT 1
- [Bug]: Click on visible element fails due to timeout in visibility check HOT 1
- [Bug]: UI Mode - 1 minute very slow at start of ui mode due to watcher watching excessive files (esp. on windows) HOT 2
- [Bug]: .NET: certificate authentication not working when running tests.
- [Feature]: Removal of `mount()` inside `test.beforeEach()` and `test.afterAll()` HOT 5
- Receiving following error message "AxiosError: Request failed with status code 401" on request HOT 1
- [Bug]: Auth Setup File Not Being Found HOT 9
- [Bug]: `Error: Playwright Test did not expect test() to be called here.` HOT 5
- [Bug]: Headers set in context.route are sent by the browsers but not available in the network tab in trace view on redirects HOT 1
- [Bug] Reusable browser clock bug
- [Bug] Check if Invalid time before sending to server
- [Bug]: npm run build-android-driver ,print error log:"cd: src/server/android/driver: No such file or directory" HOT 1
- [Bug]: no trace, video and screenshot in case of failed test (Target page, context or browser has been closed) HOT 17
- [Bug]: Playwright cannot click on a link inside a disabled input label
- [Docs]: Component testing "best practices" or "pitfalls" HOT 1
- URL redirection issue HOT 2
- [Docs]: Svelte Component Testing Hooks
- [Feature]: debug with ability to step through code for API testing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playwright.