mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
fix(types): add typed cb for Page.waitForResponse (#4575)
This commit is contained in:
parent
95c502d274
commit
d2b7e0d1df
@ -2135,7 +2135,7 @@ await page.waitForRequest(request => request.url().searchParams.get('foo') === '
|
||||
```
|
||||
|
||||
#### page.waitForResponse(urlOrPredicate[, options])
|
||||
- `urlOrPredicate` <[string]|[RegExp]|[Function]> Request URL string, regex or predicate receiving [Response] object.
|
||||
- `urlOrPredicate` <[string]|[RegExp]|[function]\([Response]\):[boolean]> Request URL string, regex or predicate receiving [Response] object.
|
||||
- `options` <[Object]> Optional waiting parameters
|
||||
- `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
|
||||
- returns: <[Promise]<[Response]>> Promise which resolves to the matched response.
|
||||
|
@ -26,7 +26,7 @@ type AssertNotAny<S> = {notRealProperty: number} extends S ? false : true;
|
||||
await page.goto('https://example.com');
|
||||
await page.screenshot({ path: 'example.png' });
|
||||
|
||||
browser.close();
|
||||
await browser.close();
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
@ -35,7 +35,7 @@ type AssertNotAny<S> = {notRealProperty: number} extends S ? false : true;
|
||||
await page.goto('https://news.ycombinator.com', { waitUntil: 'networkidle' });
|
||||
await page.pdf({ path: 'hn.pdf', format: 'A4' });
|
||||
|
||||
browser.close();
|
||||
await browser.close();
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
@ -54,7 +54,7 @@ type AssertNotAny<S> = {notRealProperty: number} extends S ? false : true;
|
||||
|
||||
console.log('Dimensions:', dimensions);
|
||||
|
||||
browser.close();
|
||||
await browser.close();
|
||||
})();
|
||||
|
||||
// The following examples are taken from the docs itself
|
||||
@ -105,7 +105,7 @@ playwright.chromium.launch().then(async browser => {
|
||||
const myHash = await (window as any).md5(myString);
|
||||
console.log(`md5 of ${myString} is ${myHash}`);
|
||||
});
|
||||
browser.close();
|
||||
await browser.close();
|
||||
|
||||
page.on('console', console.log);
|
||||
await page.exposeFunction('readfile', async (filePath: string) => {
|
||||
@ -189,7 +189,7 @@ playwright.chromium.launch().then(async browser => {
|
||||
page.on('dialog', async dialog => {
|
||||
console.log(dialog.message());
|
||||
await dialog.dismiss();
|
||||
browser.close();
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
const inputElement = (await page.$('input[type=submit]'))!;
|
||||
@ -214,7 +214,7 @@ playwright.chromium.launch().then(async browser => {
|
||||
await page.goto('https://example.com');
|
||||
await page.screenshot({ path: 'example.png' });
|
||||
|
||||
browser.close();
|
||||
await browser.close();
|
||||
})();
|
||||
|
||||
// Test v0.12 features
|
||||
@ -315,7 +315,7 @@ playwright.chromium.launch().then(async browser => {
|
||||
console.log(await resultHandle.jsonValue());
|
||||
await resultHandle.dispose();
|
||||
|
||||
browser.close();
|
||||
await browser.close();
|
||||
})();
|
||||
|
||||
// test $eval and $$eval
|
||||
@ -384,7 +384,7 @@ playwright.chromium.launch().then(async browser => {
|
||||
const assertion: AssertType<string, typeof value> = true;
|
||||
}
|
||||
}
|
||||
browser.close();
|
||||
await browser.close();
|
||||
})();
|
||||
|
||||
// waitForEvent
|
||||
@ -781,6 +781,18 @@ playwright.chromium.launch().then(async browser => {
|
||||
.off('close', listener);
|
||||
});
|
||||
|
||||
// waitForResponse callback predicate
|
||||
(async () => {
|
||||
const browser = await playwright.chromium.launch();
|
||||
const page = await browser.newPage();
|
||||
await Promise.all([
|
||||
page.waitForResponse(response => response.url().includes('example.com')),
|
||||
page.goto('https://example.com')
|
||||
]);
|
||||
|
||||
await browser.close();
|
||||
})();
|
||||
|
||||
// exported types
|
||||
import {
|
||||
LaunchOptions,
|
||||
|
Loading…
Reference in New Issue
Block a user