chore: limit docs snippet length to 100 (#24563)
This commit is contained in:
Родитель
f5d069541d
Коммит
b0473b71cd
|
@ -71,7 +71,9 @@ For example, you can use [`AxeBuilder.include()`](https://github.com/dequelabs/a
|
|||
`AxeBuilder.analyze()` will scan the page *in its current state* when you call it. To scan parts of a page that are revealed based on UI interactions, use [Locators](./locators.md) to interact with the page before invoking `analyze()`:
|
||||
|
||||
```js
|
||||
test('navigation menu flyout should not have automatically detectable accessibility violations', async ({ page }) => {
|
||||
test('navigation menu should not have automatically detectable accessibility violations', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('https://your-site.com/');
|
||||
|
||||
await page.getByRole('button', { name: 'Navigation Menu' }).click();
|
||||
|
@ -126,7 +128,9 @@ This is usually the simplest option, but it has some important downsides:
|
|||
Here is an example of excluding one element from being scanned in one specific test:
|
||||
|
||||
```js
|
||||
test('should not have any accessibility violations outside of elements with known issues', async ({ page }) => {
|
||||
test('should not have any accessibility violations outside of elements with known issues', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('https://your-site.com/page-with-known-issues');
|
||||
|
||||
const accessibilityScanResults = await new AxeBuilder({ page })
|
||||
|
@ -146,7 +150,9 @@ If your application contains many different pre-existing violations of a specifi
|
|||
You can find the rule IDs to pass to `disableRules()` in the `id` property of the violations you want to suppress. A [complete list of axe's rules](https://github.com/dequelabs/axe-core/blob/master/doc/rule-descriptions.md) can be found in `axe-core`'s documentation.
|
||||
|
||||
```js
|
||||
test('should not have any accessibility violations outside of rules with known issues', async ({ page }) => {
|
||||
test('should not have any accessibility violations outside of rules with known issues', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('https://your-site.com/page-with-known-issues');
|
||||
|
||||
const accessibilityScanResults = await new AxeBuilder({ page })
|
||||
|
|
|
@ -242,7 +242,9 @@ test('last created issue should be on the server', async ({ page }) => {
|
|||
await page.getByText('Submit new issue').click();
|
||||
const issueId = page.url().substr(page.url().lastIndexOf('/'));
|
||||
|
||||
const newIssue = await apiContext.get(`https://api.github.com/repos/${USER}/${REPO}/issues/${issueId}`);
|
||||
const newIssue = await apiContext.get(
|
||||
`https://api.github.com/repos/${USER}/${REPO}/issues/${issueId}`
|
||||
);
|
||||
expect(newIssue.ok()).toBeTruthy();
|
||||
expect(newIssue.json()).toEqual(expect.objectContaining({
|
||||
title: 'Bug report 1'
|
||||
|
@ -288,19 +290,26 @@ The main difference is that [APIRequestContext] accessible via [`property: Brows
|
|||
automatically update browser cookies if [APIResponse] has `Set-Cookie` header:
|
||||
|
||||
```js
|
||||
test('context request will share cookie storage with its browser context', async ({ page, context }) => {
|
||||
test('context request will share cookie storage with its browser context', async ({
|
||||
page,
|
||||
context,
|
||||
}) => {
|
||||
await context.route('https://www.github.com/', async route => {
|
||||
// Send an API request that shares cookie storage with the browser context.
|
||||
const response = await context.request.fetch(route.request());
|
||||
const responseHeaders = response.headers();
|
||||
|
||||
// The response will have 'Set-Cookie' header.
|
||||
const responseCookies = new Map(responseHeaders['set-cookie'].split('\n').map(c => c.split(';', 2)[0].split('=')));
|
||||
const responseCookies = new Map(responseHeaders['set-cookie']
|
||||
.split('\n')
|
||||
.map(c => c.split(';', 2)[0].split('=')));
|
||||
// The response will have 3 cookies in 'Set-Cookie' header.
|
||||
expect(responseCookies.size).toBe(3);
|
||||
const contextCookies = await context.cookies();
|
||||
// The browser context will already contain all the cookies from the API response.
|
||||
expect(new Map(contextCookies.map(({ name, value }) => [name, value]))).toEqual(responseCookies);
|
||||
expect(new Map(contextCookies.map(({ name, value }) =>
|
||||
[name, value])
|
||||
)).toEqual(responseCookies);
|
||||
|
||||
route.fulfill({
|
||||
response,
|
||||
|
@ -315,14 +324,21 @@ If you don't want [APIRequestContext] to use and update cookies from the browser
|
|||
create a new instance of [APIRequestContext] which will have its own isolated cookies:
|
||||
|
||||
```js
|
||||
test('global context request has isolated cookie storage', async ({ page, context, browser, playwright }) => {
|
||||
test('global context request has isolated cookie storage', async ({
|
||||
page,
|
||||
context,
|
||||
browser,
|
||||
playwright
|
||||
}) => {
|
||||
// Create a new instance of APIRequestContext with isolated cookie storage.
|
||||
const request = await playwright.request.newContext();
|
||||
await context.route('https://www.github.com/', async route => {
|
||||
const response = await request.fetch(route.request());
|
||||
const responseHeaders = response.headers();
|
||||
|
||||
const responseCookies = new Map(responseHeaders['set-cookie'].split('\n').map(c => c.split(';', 2)[0].split('=')));
|
||||
const responseCookies = new Map(responseHeaders['set-cookie']
|
||||
.split('\n')
|
||||
.map(c => c.split(';', 2)[0].split('=')));
|
||||
// The response will have 3 cookies in 'Set-Cookie' header.
|
||||
expect(responseCookies.size).toBe(3);
|
||||
const contextCookies = await context.cookies();
|
||||
|
@ -335,7 +351,9 @@ test('global context request has isolated cookie storage', async ({ page, contex
|
|||
const browserContext2 = await browser.newContext({ storageState });
|
||||
const contextCookies2 = await browserContext2.cookies();
|
||||
// The new browser context will already contain all the cookies from the API response.
|
||||
expect(new Map(contextCookies2.map(({ name, value }) => [name, value]))).toEqual(responseCookies);
|
||||
expect(
|
||||
new Map(contextCookies2.map(({ name, value }) => [name, value]))
|
||||
).toEqual(responseCookies);
|
||||
|
||||
route.fulfill({
|
||||
response,
|
||||
|
|
|
@ -40,8 +40,12 @@ const { _android: android } = require('playwright');
|
|||
const webview = await device.webView({ pkg: 'org.chromium.webview_shell' });
|
||||
|
||||
// Fill the input box.
|
||||
await device.fill({ res: 'org.chromium.webview_shell:id/url_field' }, 'github.com/microsoft/playwright');
|
||||
await device.press({ res: 'org.chromium.webview_shell:id/url_field' }, 'Enter');
|
||||
await device.fill({
|
||||
res: 'org.chromium.webview_shell:id/url_field',
|
||||
}, 'github.com/microsoft/playwright');
|
||||
await device.press({
|
||||
res: 'org.chromium.webview_shell:id/url_field',
|
||||
}, 'Enter');
|
||||
|
||||
// Work with WebView's page as usual.
|
||||
const page = await webview.page();
|
||||
|
|
|
@ -768,7 +768,9 @@ const crypto = require('crypto');
|
|||
(async () => {
|
||||
const browser = await webkit.launch({ headless: false });
|
||||
const context = await browser.newContext();
|
||||
await context.exposeFunction('sha256', text => crypto.createHash('sha256').update(text).digest('hex'));
|
||||
await context.exposeFunction('sha256', text =>
|
||||
crypto.createHash('sha256').update(text).digest('hex'),
|
||||
);
|
||||
const page = await context.newPage();
|
||||
await page.setContent(`
|
||||
<script>
|
||||
|
|
|
@ -466,7 +466,9 @@ value.
|
|||
|
||||
```js
|
||||
const feedHandle = await page.$('.feed');
|
||||
expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
||||
expect(await feedHandle.$$eval('.tweet', nodes =>
|
||||
nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!'],
|
||||
);
|
||||
```
|
||||
|
||||
```java
|
||||
|
|
|
@ -677,7 +677,9 @@ Console.WriteLine(await frame.EvaluateAsync<int>("1 + 2")); // prints "3"
|
|||
|
||||
```js
|
||||
const bodyHandle = await frame.evaluate('document.body');
|
||||
const html = await frame.evaluate(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']);
|
||||
const html = await frame.evaluate(([body, suffix]) =>
|
||||
body.innerHTML + suffix, [bodyHandle, 'hello'],
|
||||
);
|
||||
await bodyHandle.dispose();
|
||||
```
|
||||
|
||||
|
@ -782,7 +784,9 @@ var docHandle = await frame.EvaluateHandleAsync("document"); // Handle for the `
|
|||
|
||||
```js
|
||||
const aHandle = await frame.evaluateHandle(() => document.body);
|
||||
const resultHandle = await frame.evaluateHandle(([body, suffix]) => body.innerHTML + suffix, [aHandle, 'hello']);
|
||||
const resultHandle = await frame.evaluateHandle(([body, suffix]) =>
|
||||
body.innerHTML + suffix, [aHandle, 'hello'],
|
||||
);
|
||||
console.log(await resultHandle.jsonValue());
|
||||
await resultHandle.dispose();
|
||||
```
|
||||
|
|
|
@ -1508,7 +1508,9 @@ Console.WriteLine(await page.EvaluateAsync<int>("1 + 2")); // prints "3"
|
|||
|
||||
```js
|
||||
const bodyHandle = await page.evaluate('document.body');
|
||||
const html = await page.evaluate<string, HTMLElement>(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']);
|
||||
const html = await page.evaluate<string, HTMLElement>(([body, suffix]) =>
|
||||
body.innerHTML + suffix, [bodyHandle, 'hello']
|
||||
);
|
||||
await bodyHandle.dispose();
|
||||
```
|
||||
|
||||
|
@ -1920,7 +1922,9 @@ const crypto = require('crypto');
|
|||
(async () => {
|
||||
const browser = await webkit.launch({ headless: false });
|
||||
const page = await browser.newPage();
|
||||
await page.exposeFunction('sha256', text => crypto.createHash('sha256').update(text).digest('hex'));
|
||||
await page.exposeFunction('sha256', text =>
|
||||
crypto.createHash('sha256').update(text).digest('hex'),
|
||||
);
|
||||
await page.setContent(`
|
||||
<script>
|
||||
async function onClick() {
|
||||
|
@ -4440,7 +4444,9 @@ await page.getByText('trigger request').click();
|
|||
const request = await requestPromise;
|
||||
|
||||
// Alternative way with a predicate. Note no await.
|
||||
const requestPromise = page.waitForRequest(request => request.url() === 'https://example.com' && request.method() === 'GET');
|
||||
const requestPromise = page.waitForRequest(request =>
|
||||
request.url() === 'https://example.com' && request.method() === 'GET',
|
||||
);
|
||||
await page.getByText('trigger request').click();
|
||||
const request = await requestPromise;
|
||||
```
|
||||
|
@ -4577,7 +4583,9 @@ await page.getByText('trigger response').click();
|
|||
const response = await responsePromise;
|
||||
|
||||
// Alternative way with a predicate. Note no await.
|
||||
const responsePromise = page.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200);
|
||||
const responsePromise = page.waitForResponse(response =>
|
||||
response.url() === 'https://example.com' && response.status() === 200
|
||||
);
|
||||
await page.getByText('trigger response').click();
|
||||
const response = await responsePromise;
|
||||
```
|
||||
|
|
|
@ -221,7 +221,9 @@ const pathToExtension = path.join(__dirname, 'my-extension');
|
|||
const context = await chromium.launchPersistentContext('', {
|
||||
headless: false,
|
||||
args: [
|
||||
`--headless=new`, // the new headless arg for chrome v109+. Use '--headless=chrome' as arg for browsers v94-108.
|
||||
// the new headless arg for chrome v109+. Use '--headless=chrome'
|
||||
// as arg for browsers v94-108.
|
||||
`--headless=new`,
|
||||
`--disable-extensions-except=${pathToExtension}`,
|
||||
`--load-extension=${pathToExtension}`,
|
||||
],
|
||||
|
|
|
@ -632,7 +632,9 @@ elements that can be selected by one of the selectors in that list.
|
|||
|
||||
```js
|
||||
// Waits for either confirmation dialog or load spinner.
|
||||
await page.locator(`//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']`).waitFor();
|
||||
await page.locator(
|
||||
`//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']`
|
||||
).waitFor();
|
||||
```
|
||||
|
||||
```java
|
||||
|
|
|
@ -25,7 +25,11 @@ exports.PlaywrightDevPage = class PlaywrightDevPage {
|
|||
this.page = page;
|
||||
this.getStartedLink = page.locator('a', { hasText: 'Get started' });
|
||||
this.gettingStartedHeader = page.locator('h1', { hasText: 'Installation' });
|
||||
this.pomLink = page.locator('li', { hasText: 'Guides' }).locator('a', { hasText: 'Page Object Model' });
|
||||
this.pomLink = page.locator('li', {
|
||||
hasText: 'Guides',
|
||||
}).locator('a', {
|
||||
hasText: 'Page Object Model',
|
||||
});
|
||||
this.tocList = page.locator('article div.markdown ul > li > a');
|
||||
}
|
||||
|
||||
|
@ -59,7 +63,11 @@ export class PlaywrightDevPage {
|
|||
this.page = page;
|
||||
this.getStartedLink = page.locator('a', { hasText: 'Get started' });
|
||||
this.gettingStartedHeader = page.locator('h1', { hasText: 'Installation' });
|
||||
this.pomLink = page.locator('li', { hasText: 'Guides' }).locator('a', { hasText: 'Page Object Model' });
|
||||
this.pomLink = page.locator('li', {
|
||||
hasText: 'Guides',
|
||||
}).locator('a', {
|
||||
hasText: 'Page Object Model',
|
||||
});
|
||||
this.tocList = page.locator('article div.markdown ul > li > a');
|
||||
}
|
||||
|
||||
|
@ -88,7 +96,11 @@ class PlaywrightDevPage {
|
|||
this.page = page;
|
||||
this.getStartedLink = page.locator('a', { hasText: 'Get started' });
|
||||
this.gettingStartedHeader = page.locator('h1', { hasText: 'Installation' });
|
||||
this.pomLink = page.locator('li', { hasText: 'Playwright Test' }).locator('a', { hasText: 'Page Object Model' });
|
||||
this.pomLink = page.locator('li', {
|
||||
hasText: 'Playwright Test',
|
||||
}).locator('a', {
|
||||
hasText: 'Page Object Model',
|
||||
});
|
||||
this.tocList = page.locator('article div.markdown ul > li > a');
|
||||
}
|
||||
async getStarted() {
|
||||
|
|
|
@ -42,7 +42,9 @@ await page.evaluate(async () => {
|
|||
const registration = await window.navigator.serviceWorker.getRegistration();
|
||||
if (registration.active?.state === 'activated')
|
||||
return;
|
||||
await new Promise(res => window.navigator.serviceWorker.addEventListener('controllerchange', res));
|
||||
await new Promise(res =>
|
||||
window.navigator.serviceWorker.addEventListener('controllerchange', res),
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
|
|
|
@ -162,7 +162,10 @@ It's also possible to add custom metadata in the form of annotations to your tes
|
|||
```js title="example.spec.ts"
|
||||
|
||||
test('user profile', async ({ page }) => {
|
||||
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/<some-issue>' });
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
description: 'https://github.com/microsoft/playwright/issues/<some-issue>',
|
||||
});
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
|
|
@ -889,7 +889,10 @@ Returns information about the currently running test. This method can only be ca
|
|||
```js
|
||||
test('example test', async ({ page }) => {
|
||||
// ...
|
||||
await test.info().attach('screenshot', { body: await page.screenshot(), contentType: 'image/png' });
|
||||
await test.info().attach('screenshot', {
|
||||
body: await page.screenshot(),
|
||||
contentType: 'image/png',
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
|
|
|
@ -203,7 +203,8 @@ await expect.poll(async () => {
|
|||
const response = await page.request.get('https://api.example.com');
|
||||
return response.status();
|
||||
}, {
|
||||
// Probe, wait 1s, probe, wait 2s, probe, wait 10s, probe, wait 10s, probe, .... Defaults to [100, 250, 500, 1000].
|
||||
// Probe, wait 1s, probe, wait 2s, probe, wait 10s, probe, wait 10s, probe
|
||||
// ... Defaults to [100, 250, 500, 1000].
|
||||
intervals: [1_000, 2_000, 10_000],
|
||||
timeout: 60_000
|
||||
}).toBe(200);
|
||||
|
@ -227,7 +228,8 @@ await expect(async () => {
|
|||
const response = await page.request.get('https://api.example.com');
|
||||
expect(response.status()).toBe(200);
|
||||
}).toPass({
|
||||
// Probe, wait 1s, probe, wait 2s, probe, wait 10s, probe, wait 10s, probe, .... Defaults to [100, 250, 500, 1000].
|
||||
// Probe, wait 1s, probe, wait 2s, probe, wait 10s, probe, wait 10s, probe
|
||||
// ... Defaults to [100, 250, 500, 1000].
|
||||
intervals: [1_000, 2_000, 10_000],
|
||||
timeout: 60_000
|
||||
});
|
||||
|
|
|
@ -133,7 +133,8 @@ export default defineConfig({
|
|||
},
|
||||
|
||||
toMatchSnapshot: {
|
||||
// An acceptable ratio of pixels that are different to the total amount of pixels, between 0 and 1.
|
||||
// An acceptable ratio of pixels that are different to the
|
||||
// total amount of pixels, between 0 and 1.
|
||||
maxDiffPixelRatio: 0.1,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -36,7 +36,9 @@ module.exports = MyReporter;
|
|||
```
|
||||
|
||||
```js tab=js-ts title="my-awesome-reporter.ts"
|
||||
import type { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
|
||||
import type {
|
||||
Reporter, FullConfig, Suite, TestCase, TestResult, FullResult
|
||||
} from '@playwright/test/reporter';
|
||||
|
||||
class MyReporter implements Reporter {
|
||||
constructor(options: { customOption?: string } = {}) {
|
||||
|
|
|
@ -289,7 +289,9 @@ export default defineConfig({
|
|||
You can create a custom reporter by implementing a class with some of the reporter methods. Learn more about the [Reporter] API.
|
||||
|
||||
```js title="my-awesome-reporter.ts"
|
||||
import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter';
|
||||
import type {
|
||||
FullConfig, FullResult, Reporter, Suite, TestCase, TestResult
|
||||
} from '@playwright/test/reporter';
|
||||
|
||||
class MyReporter implements Reporter {
|
||||
onBegin(config: FullConfig, suite: Suite) {
|
||||
|
|
|
@ -224,9 +224,9 @@ export default defineConfig({
|
|||
An example test illustrating the initial context options are set:
|
||||
|
||||
```js
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('should inherit use options on context when using built-in browser fixture', async ({ browser }) => {
|
||||
test('should inherit use options on context when using built-in browser fixture', async ({
|
||||
browser,
|
||||
}) => {
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
expect(await page.evaluate(() => navigator.userAgent)).toBe('some custom ua');
|
||||
|
|
|
@ -75,13 +75,20 @@ import os from 'os';
|
|||
import path from 'path';
|
||||
import childProcess from 'child_process';
|
||||
|
||||
const EXECUTABLE_PATH = path.join(__dirname, '../../webview2-app/bin/Debug/net6.0-windows/webview2.exe');
|
||||
const EXECUTABLE_PATH = path.join(
|
||||
__dirname,
|
||||
'../../webview2-app/bin/Debug/net6.0-windows/webview2.exe',
|
||||
);
|
||||
|
||||
export const test = base.extend({
|
||||
browser: async ({ playwright }, use, testInfo) => {
|
||||
const cdpPort = 10000 + testInfo.workerIndex;
|
||||
fs.accessSync(EXECUTABLE_PATH, fs.constants.X_OK); // Make sure that the executable exists and is executable
|
||||
const userDataDir = path.join(fs.realpathSync.native(os.tmpdir()), `playwright-webview2-tests/user-data-dir-${testInfo.workerIndex}`);
|
||||
// Make sure that the executable exists and is executable
|
||||
fs.accessSync(EXECUTABLE_PATH, fs.constants.X_OK);
|
||||
const userDataDir = path.join(
|
||||
fs.realpathSync.native(os.tmpdir()),
|
||||
`playwright-webview2-tests/user-data-dir-${testInfo.workerIndex}`,
|
||||
);
|
||||
const webView2Process = childProcess.spawn(EXECUTABLE_PATH, [], {
|
||||
shell: true,
|
||||
env: {
|
||||
|
|
|
@ -112,7 +112,9 @@ export interface Page {
|
|||
*
|
||||
* ```js
|
||||
* const bodyHandle = await page.evaluate('document.body');
|
||||
* const html = await page.evaluate<string, HTMLElement>(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']);
|
||||
* const html = await page.evaluate<string, HTMLElement>(([body, suffix]) =>
|
||||
* body.innerHTML + suffix, [bodyHandle, 'hello']
|
||||
* );
|
||||
* await bodyHandle.dispose();
|
||||
* ```
|
||||
*
|
||||
|
@ -159,7 +161,9 @@ export interface Page {
|
|||
*
|
||||
* ```js
|
||||
* const bodyHandle = await page.evaluate('document.body');
|
||||
* const html = await page.evaluate<string, HTMLElement>(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']);
|
||||
* const html = await page.evaluate<string, HTMLElement>(([body, suffix]) =>
|
||||
* body.innerHTML + suffix, [bodyHandle, 'hello']
|
||||
* );
|
||||
* await bodyHandle.dispose();
|
||||
* ```
|
||||
*
|
||||
|
@ -2316,7 +2320,9 @@ export interface Page {
|
|||
* (async () => {
|
||||
* const browser = await webkit.launch({ headless: false });
|
||||
* const page = await browser.newPage();
|
||||
* await page.exposeFunction('sha256', text => crypto.createHash('sha256').update(text).digest('hex'));
|
||||
* await page.exposeFunction('sha256', text =>
|
||||
* crypto.createHash('sha256').update(text).digest('hex'),
|
||||
* );
|
||||
* await page.setContent(`
|
||||
* <script>
|
||||
* async function onClick() {
|
||||
|
@ -4552,7 +4558,9 @@ export interface Page {
|
|||
* const request = await requestPromise;
|
||||
*
|
||||
* // Alternative way with a predicate. Note no await.
|
||||
* const requestPromise = page.waitForRequest(request => request.url() === 'https://example.com' && request.method() === 'GET');
|
||||
* const requestPromise = page.waitForRequest(request =>
|
||||
* request.url() === 'https://example.com' && request.method() === 'GET',
|
||||
* );
|
||||
* await page.getByText('trigger request').click();
|
||||
* const request = await requestPromise;
|
||||
* ```
|
||||
|
@ -4582,7 +4590,9 @@ export interface Page {
|
|||
* const response = await responsePromise;
|
||||
*
|
||||
* // Alternative way with a predicate. Note no await.
|
||||
* const responsePromise = page.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200);
|
||||
* const responsePromise = page.waitForResponse(response =>
|
||||
* response.url() === 'https://example.com' && response.status() === 200
|
||||
* );
|
||||
* await page.getByText('trigger response').click();
|
||||
* const response = await responsePromise;
|
||||
* ```
|
||||
|
@ -4768,7 +4778,9 @@ export interface Frame {
|
|||
*
|
||||
* ```js
|
||||
* const bodyHandle = await frame.evaluate('document.body');
|
||||
* const html = await frame.evaluate(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']);
|
||||
* const html = await frame.evaluate(([body, suffix]) =>
|
||||
* body.innerHTML + suffix, [bodyHandle, 'hello'],
|
||||
* );
|
||||
* await bodyHandle.dispose();
|
||||
* ```
|
||||
*
|
||||
|
@ -4811,7 +4823,9 @@ export interface Frame {
|
|||
*
|
||||
* ```js
|
||||
* const bodyHandle = await frame.evaluate('document.body');
|
||||
* const html = await frame.evaluate(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']);
|
||||
* const html = await frame.evaluate(([body, suffix]) =>
|
||||
* body.innerHTML + suffix, [bodyHandle, 'hello'],
|
||||
* );
|
||||
* await bodyHandle.dispose();
|
||||
* ```
|
||||
*
|
||||
|
@ -4853,7 +4867,9 @@ export interface Frame {
|
|||
*
|
||||
* ```js
|
||||
* const aHandle = await frame.evaluateHandle(() => document.body);
|
||||
* const resultHandle = await frame.evaluateHandle(([body, suffix]) => body.innerHTML + suffix, [aHandle, 'hello']);
|
||||
* const resultHandle = await frame.evaluateHandle(([body, suffix]) =>
|
||||
* body.innerHTML + suffix, [aHandle, 'hello'],
|
||||
* );
|
||||
* console.log(await resultHandle.jsonValue());
|
||||
* await resultHandle.dispose();
|
||||
* ```
|
||||
|
@ -4895,7 +4911,9 @@ export interface Frame {
|
|||
*
|
||||
* ```js
|
||||
* const aHandle = await frame.evaluateHandle(() => document.body);
|
||||
* const resultHandle = await frame.evaluateHandle(([body, suffix]) => body.innerHTML + suffix, [aHandle, 'hello']);
|
||||
* const resultHandle = await frame.evaluateHandle(([body, suffix]) =>
|
||||
* body.innerHTML + suffix, [aHandle, 'hello'],
|
||||
* );
|
||||
* console.log(await resultHandle.jsonValue());
|
||||
* await resultHandle.dispose();
|
||||
* ```
|
||||
|
@ -8197,7 +8215,9 @@ export interface BrowserContext {
|
|||
* (async () => {
|
||||
* const browser = await webkit.launch({ headless: false });
|
||||
* const context = await browser.newContext();
|
||||
* await context.exposeFunction('sha256', text => crypto.createHash('sha256').update(text).digest('hex'));
|
||||
* await context.exposeFunction('sha256', text =>
|
||||
* crypto.createHash('sha256').update(text).digest('hex'),
|
||||
* );
|
||||
* const page = await context.newPage();
|
||||
* await page.setContent(`
|
||||
* <script>
|
||||
|
@ -9119,7 +9139,9 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
|
|||
*
|
||||
* ```js
|
||||
* const feedHandle = await page.$('.feed');
|
||||
* expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
||||
* expect(await feedHandle.$$eval('.tweet', nodes =>
|
||||
* nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!'],
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @param selector A selector to query for.
|
||||
|
@ -9148,7 +9170,9 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
|
|||
*
|
||||
* ```js
|
||||
* const feedHandle = await page.$('.feed');
|
||||
* expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
||||
* expect(await feedHandle.$$eval('.tweet', nodes =>
|
||||
* nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!'],
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @param selector A selector to query for.
|
||||
|
@ -9177,7 +9201,9 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
|
|||
*
|
||||
* ```js
|
||||
* const feedHandle = await page.$('.feed');
|
||||
* expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
||||
* expect(await feedHandle.$$eval('.tweet', nodes =>
|
||||
* nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!'],
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @param selector A selector to query for.
|
||||
|
@ -9206,7 +9232,9 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
|
|||
*
|
||||
* ```js
|
||||
* const feedHandle = await page.$('.feed');
|
||||
* expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
||||
* expect(await feedHandle.$$eval('.tweet', nodes =>
|
||||
* nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!'],
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @param selector A selector to query for.
|
||||
|
@ -13711,8 +13739,12 @@ export {};
|
|||
* const webview = await device.webView({ pkg: 'org.chromium.webview_shell' });
|
||||
*
|
||||
* // Fill the input box.
|
||||
* await device.fill({ res: 'org.chromium.webview_shell:id/url_field' }, 'github.com/microsoft/playwright');
|
||||
* await device.press({ res: 'org.chromium.webview_shell:id/url_field' }, 'Enter');
|
||||
* await device.fill({
|
||||
* res: 'org.chromium.webview_shell:id/url_field',
|
||||
* }, 'github.com/microsoft/playwright');
|
||||
* await device.press({
|
||||
* res: 'org.chromium.webview_shell:id/url_field',
|
||||
* }, 'Enter');
|
||||
*
|
||||
* // Work with WebView's page as usual.
|
||||
* const page = await webview.page();
|
||||
|
|
|
@ -3351,7 +3351,10 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
|
|||
* ```js
|
||||
* test('example test', async ({ page }) => {
|
||||
* // ...
|
||||
* await test.info().attach('screenshot', { body: await page.screenshot(), contentType: 'image/png' });
|
||||
* await test.info().attach('screenshot', {
|
||||
* body: await page.screenshot(),
|
||||
* contentType: 'image/png',
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
|
|
|
@ -316,7 +316,9 @@ export interface FullResult {
|
|||
*
|
||||
* ```js
|
||||
* // my-awesome-reporter.ts
|
||||
* import type { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
|
||||
* import type {
|
||||
* Reporter, FullConfig, Suite, TestCase, TestResult, FullResult
|
||||
* } from '@playwright/test/reporter';
|
||||
*
|
||||
* class MyReporter implements Reporter {
|
||||
* constructor(options: { customOption?: string } = {}) {
|
||||
|
|
|
@ -142,6 +142,7 @@ class JSLintingService extends LintingService {
|
|||
rules: {
|
||||
'notice/notice': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'max-len': ['error', { code: 100 }],
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче