Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Clarify playwright screenshots issue #2437

Merged
merged 6 commits into from
Sep 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,27 @@ You can use Playwright to test your app on any browser and emulate a real device

:::note
Playwright is not a real Emulator or Simulator. It just emulates the browser behavior such as `userAgent`, `screenSize`, `viewport` and etc.
:::
:::

## Screenshots

tianfeng92 marked this conversation as resolved.
Show resolved Hide resolved
To enable Playwright screenshot capture, please refer to the [Playwright Config](https://playwright.dev/docs/test-configuration#automatic-screenshots).

By default, Playwright generates screenshot files in the following structure:

```
demo-todo-app-Editing-should-save-edits-on-blur-webkit
demo-todo-app-Editing-should-save-edits-on-blur-webkit/test-finished-1.png
demo-todo-app-Routing-should-allow-me-to-display-all-items-chromium
demo-todo-app-Routing-should-allow-me-to-display-all-items-chromium/test-finished-1.png
```

However, Sauce Labs only supports uploading flattened files, which means that `test-finished-1.png` would be uploaded and overwritten. To set a unique screenshot name, you can refer to the [Playwright Screenshot documentation](https://playwright.dev/docs/screenshots) and set it as follows:

```javascript
test('take a screenshot', async ({ page }, testInfo) => {
await page.goto('https://playwright.dev/');
await page.screenshot({ path: 'screen_capture_unique_name.png' });
await testInfo.attach('screen_capture_unique_name.png', { path: 'screen_capture_unique_name.png', contentType: 'image/png' });
});
```
Loading