docs(library) fix js example (#17933)

Co-authored-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
John Hawkinson 2022-10-10 14:54:17 -04:00 committed by GitHub
parent 6b01df6d92
commit a62a67fba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ The following is an example of using the Playwright Library directly to launch C
```js tab=js-ts
import playwright, { devices } from 'playwright';
import assert from 'node:assert';
(async () => {
// Setup
@ -35,7 +36,7 @@ import playwright, { devices } from 'playwright';
await context.route('**.jpg', route => route.abort());
await page.goto('https://example.com/');
assert(await page.title() === 'Example'); // 👎 not a Web First assertion
assert(await page.title() === 'Example Domain'); // 👎 not a Web First assertion
// Teardown
await context.close();
@ -44,19 +45,20 @@ import playwright, { devices } from 'playwright';
```
```js tab=js-js
const assert = require('node:assert');
const playwright = require('playwright');
(async () => {
// Setup
const browser = await playwright.chromium.launch();
const context = await browser.newContext(devices['iPhone 11']);
const context = await browser.newContext(playwright.devices['iPhone 11']);
const page = await context.newPage();
// The actual interesting bit
await context.route('**.jpg', route => route.abort());
await page.goto('https://example.com/');
assert(await page.title() === 'Example'); // 👎 not a Web First assertion
assert(await page.title() === 'Example Domain'); // 👎 not a Web First assertion
// Teardown
await context.close();