我目前正在学习Puppeteer API,并正在使用v1.9.0。我尝试从iframe中单击按钮时获得以下代码:
const changePrefsFromAllToNone = async () => {
try {
const browser = await puppeteer.launch({
headless:false,
slowMo: 250});
const page = await browser.newPage();
await page.setViewport({width: 1280, height: 800});
await page.goto(baseUrl);
await page.waitForSelector('.widget-title');
const frame = page.frames().find(f => f.name() === 'iframe');
const prefsDenyButton = await frame.$eval('#option-refuse-phv1L');
prefsDenyButton.click();
} catch (error) {
console.log(error);
}
};
changePrefsFromAllToNone();
,错误为:
Error: The following is not a function: undefined
at ExecutionContext.evaluateHandle
我使用的是直接来自puppeteer网站的示例: https://github.com/GoogleChrome/puppeteer/blob/v1.9.0/docs/api.md#