本文整理汇总了TypeScript中puppeteer.Page.waitForFunction方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Page.waitForFunction方法的具体用法?TypeScript Page.waitForFunction怎么用?TypeScript Page.waitForFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类puppeteer.Page
的用法示例。
在下文中一共展示了Page.waitForFunction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
export const waitToDisappear = async (page: Page, selector: string): Promise<void> => {
return page.waitForFunction(
(_selector: string) => !document.querySelector(_selector),
{},
selector
);
};
示例2: async
const toggleEnabled = async (id: number) => {
const origEnabled = await enabledState(id).toString();
await page.click(switchSelctor(id));
await page.waitForFunction(
`document.querySelector("${switchSelctor(
id
)}").getAttribute("data-enabled") !== "${origEnabled}"`
);
};
示例3: inDetailPage
await inDetailPage(1, async () => {
expect(
await (await (await page.$('.config-save'))!.getProperty(
'disabled'
)).jsonValue()
).toBe(true);
await page.waitForSelector('.CodeMirror .CodeMirror-code');
await page.waitForFunction(
'document.querySelector(".CodeMirror .CodeMirror-code").innerText.toLowerCase().indexOf("loading")<0'
);
await page.click('.CodeMirror .CodeMirror-code > div');
await page.keyboard.press('x');
await page.waitForFunction(
'document.querySelector(".config-save") && !document.querySelector(".config-save").disabled'
);
await page.click('.config-save');
await page.waitForFunction('document.querySelector(".config-save").disabled');
});
示例4: readyAngular
public async readyAngular(page: Page): Promise<void> {
log.verbose('PuppetPuppeteerBridge', 'readyAngular()')
try {
await page.waitForFunction(`typeof window.angular !== 'undefined'`)
} catch (e) {
log.verbose('PuppetPuppeteerBridge', 'readyAngular() exception: %s', e)
const blockedMessage = await this.testBlockedMessage()
if (blockedMessage) { // Wechat Account Blocked
// TODO: advertise for puppet-padchat
log.info('PuppetPuppeteerBridge', `
Please see: Account Login Issue <https://github.com/Chatie/wechaty/issues/872>
`)
throw new Error(blockedMessage)
} else {
throw e
}
}
}