Skip to main content
Version: 23.8.0

Frame.waitForNavigation() 方法

¥Frame.waitForNavigation() method

等待框架导航。当你运行将间接导致框架导航的代码时,它非常有用。

¥Waits for the frame to navigate. It is useful for when you run code which will indirectly cause the frame to navigate.

使用 历史 API 更改 URL 被视为导航。

¥Usage of the History API to change the URL is considered a navigation.

签名

¥Signature

class Frame {
abstract waitForNavigation(
options?: WaitForOptions,
): Promise<HTTPResponse | null>;
}

参数

¥Parameters

范围

类型

描述

options

WaitForOptions

(可选的)配置等待行为的选项。

Returns:

Promise<HTTPResponse | null>

解析为主要资源响应的 promise。

¥A promise which resolves to the main resource response.

示例

¥Example

const [response] = await Promise.all([
// The navigation promise resolves after navigation has finished
frame.waitForNavigation(),
// Clicking the link will indirectly cause a navigation
frame.click('a.my-link'),
]);