Skip to content

Commit

Permalink
Merge b5f17fa into 37e7955
Browse files Browse the repository at this point in the history
  • Loading branch information
tianfeng92 authored Sep 13, 2023
2 parents 37e7955 + b5f17fa commit f6483f8
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,29 @@ 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

To get trackable screenshots in Sauce Cloud, please refer to the [Playwright Screenshot documentation](https://playwright.dev/docs/screenshots) and implement the following code snippet:

```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' });
});
```

:::caution
Please be aware that using the default screenshot setting in the [Playwright Config](https://playwright.dev/docs/test-use-options#recording-options) may result in potential issues on Sauce Labs. 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, resulting in only one `test-finished-1.png` existing.
:::

0 comments on commit f6483f8

Please sign in to comment.