错误如下行:
await page.waitForFunction('document.querySelector(".eo-validation-code").innerText.length == 32');
在上下文中:
const puppeteer = require('puppeteer');
puppeteer.launch({ignoreHTTPSErrors: true, headless: false}).then(async browser => {
const page = await browser.newPage();
console.log(2);
await page.setViewport({ width: 500, height: 400 });
console.log(3)
const res = await page.goto('https://apps.realmail.dk/scratchcards/eovendo/gui/index.php?UserId=60sEBfXq6wNExN4%2bn9YSBw%3d%3d&ServiceId=f147263e75262ecc82d695e795a32f4d');
console.log(4)
await page.waitForFunction('document.querySelector(".eo-validation-code").innerText.length == 32').catch(err => console.log(err));
这基本上是此答案的副本:https://stackoverflow.com/a/46825433/10238810 除了我已更改querySelector,以查找具有类名称“ eo-validation-code”的元素。
答案 0 :(得分:2)
您在r
中的innerText
符号出了问题(我认为可能是BOM)
试试吧:
const puppeteer = require('puppeteer');
puppeteer.launch({ignoreHTTPSErrors: true, headless: false}).then(async browser => {
const page = await browser.newPage();
console.log(2);
await page.setViewport({ width: 500, height: 400 });
console.log(3)
const res = await page.goto('https://apps.realmail.dk/scratchcards/eovendo/gui/index.php?UserId=60sEBfXq6wNExN4%2bn9YSBw%3d%3d&ServiceId=f147263e75262ecc82d695e795a32f4d');
console.log(4)
await page.waitForFunction('document.querySelector(".eo-validation-code").innerText.length == 32').catch(err => console.log(err));