Skip to content

Commit b1cb01b

Browse files
authored
Update playwright.mdx
updated through assertions. need to update -how to reuse sessions using playwright -update features
1 parent 63ff1ab commit b1cb01b

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

src/content/docs/browser-rendering/platform/playwright.mdx

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ The current version of the Playwright is [**v1.55.0**](https://github.com/cloudf
2828

2929
## Use Playwright in a Worker
3030

31+
In this [example](https://github.com/cloudflare/playwright/tree/main/packages/playwright-cloudflare/examples/todomvc), you will run Playwright tests in a Cloudflare Worker using the [todomvc](https://demo.playwright.dev/todomvc) application.
32+
33+
If you want to skip the steps and get started quickly, select **Deploy to Cloudflare** below.
34+
35+
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/playwright/tree/main/packages/playwright-cloudflare/examples/todomvc)
36+
3137
Make sure you have the [browser binding](/browser-rendering/platform/wrangler/#bindings) configured in your `wrangler.toml` file:
3238

3339
<WranglerConfig>
@@ -36,13 +42,10 @@ Make sure you have the [browser binding](/browser-rendering/platform/wrangler/#b
3642
name = "cloudflare-playwright-example"
3743
main = "src/index.ts"
3844
workers_dev = true
39-
compatibility_flags = ["nodejs_compat_v2"]
40-
compatibility_date = "2025-03-05"
45+
compatibility_flags = ["nodejs_compat"]
46+
compatibility_date = "2025-09-17"
4147
upload_source_maps = true
4248

43-
[dev]
44-
port = 9000
45-
4649
[browser]
4750
binding = "MYBROWSER"
4851
```
@@ -60,11 +63,7 @@ Let's look at some examples of how to use Playwright:
6063
Using browser automation to take screenshots of web pages is a common use case. This script tells the browser to navigate to https://demo.playwright.dev/todomvc, create some items, take a screenshot of the page, and return the image in the response.
6164

6265
```ts
63-
import { launch, type BrowserWorker } from "@cloudflare/playwright";
64-
65-
interface Env {
66-
MYBROWSER: BrowserWorker;
67-
}
66+
import { launch } from "@cloudflare/playwright";
6867

6968
export default {
7069
async fetch(request: Request, env: Env) {
@@ -104,12 +103,8 @@ A Playwright trace is a detailed log of your workflow execution that captures in
104103
Here's an example of a worker generating a trace file:
105104

106105
```ts
107-
import { launch, type BrowserWorker } from "@cloudflare/playwright";
108-
import fs from "@cloudflare/playwright/fs";
109-
110-
interface Env {
111-
MYBROWSER: BrowserWorker;
112-
}
106+
import fs from "fs";
107+
import { launch } from "@cloudflare/playwright";
113108

114109
export default {
115110
async fetch(request: Request, env: Env) {
@@ -153,13 +148,9 @@ export default {
153148
One of the most common use cases for using Playwright is software testing. Playwright includes test assertion features in its APIs; refer to [Assertions](https://playwright.dev/docs/test-assertions) in the Playwright documentation for details. Here's an example of a Worker doing `expect()` test assertions of the [todomvc](https://demo.playwright.dev/todomvc) demo page:
154149

155150
```ts
156-
import { launch, type BrowserWorker } from "@cloudflare/playwright";
151+
import { launch } from "@cloudflare/playwright";
157152
import { expect } from "@cloudflare/playwright/test";
158153

159-
interface Env {
160-
MYBROWSER: BrowserWorker;
161-
}
162-
163154
export default {
164155
async fetch(request: Request, env: Env) {
165156
const browser = await launch(env.MYBROWSER);
@@ -293,7 +284,7 @@ You should also be able to access this information in the dashboard, albeit with
293284

294285
The full Playwright API can be found at the [Playwright API documentation](https://playwright.dev/docs/api/class-playwright).
295286

296-
Note that `@cloudflare/playwright` is in beta. The following capabilities are not yet fully supported, but we’re actively working on them:
287+
The following capabilities are not yet fully supported, but we’re actively working on them:
297288

298289
- [API Testing](https://playwright.dev/docs/api-testing)
299290
- [Playwright Test](https://playwright.dev/docs/test-configuration) except [Assertions](https://playwright.dev/docs/test-assertions)

0 commit comments

Comments
 (0)