Page.waitForFrame() 方法
等待符合给定条件的框架出现。
签名
class Page {
waitForFrame(
urlOrPredicate: string | ((frame: Frame) => Awaitable<boolean>),
options?: WaitTimeoutOptions,
): Promise<Frame>;
}
参数
|
参数 |
类型 |
说明 |
|---|---|---|
|
urlOrPredicate | ||
|
options |
(可选) |
返回值:
Promise<Frame>
示例
const frame = await page.waitForFrame(async frame => {
const frameElement = await frame.frameElement();
if (!frameElement) {
return false;
}
const name = await frameElement.evaluate(el => el.getAttribute('name'));
return name === 'test';
});