mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
docs(library) fix js example (#17933)
Co-authored-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
parent
6b01df6d92
commit
a62a67fba3
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user