Page.waitForResponse() メソッド
シグネチャ:
class Page {
waitForResponse(
urlOrPredicate: string | AwaitablePredicate<HTTPResponse>,
options?: WaitTimeoutOptions
): Promise<HTTPResponse>;
}
パラメータ
パラメータ | 型 | 説明 |
---|---|---|
urlOrPredicate | string | AwaitablePredicate<HTTPResponse> | 待機するURLまたは述語。 |
options | WaitTimeoutOptions | (オプション) オプションの待機パラメータ |
戻り値
Promise<HTTPResponse>
一致するレスポンスで解決されるPromise。
備考
オプションパラメータ
timeout
: 最大待機時間(ミリ秒)。デフォルトは30
秒。タイムアウトを無効にするには0
を渡します。デフォルト値はPage.setDefaultTimeout()メソッドを使用して変更できます。
例
const firstResponse = await page.waitForResponse(
'https://example.com/resource'
);
const finalResponse = await page.waitForResponse(
response =>
response.url() === 'https://example.com' && response.status() === 200
);
const finalResponse = await page.waitForResponse(async response => {
return (await response.text()).includes('<html>');
});
return finalResponse.ok();