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.
使用 History 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
范围 🌐 Parameter | 类型 🌐 Type | 描述 🌐 Description |
|---|---|---|
options | (可选) 配置等待行为的选项。 🌐 (Optional) Options to configure waiting behavior. |
返回:
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'),
]);