木偶(评估失败:语法错误:令牌无效或意外)

时间:2018-08-20 20:16:46

标签: javascript node.js puppeteer

错误如下行:

await page.waitForFunction('document.querySelector(".eo-validation-code").inner‌​Text.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").inner‌​Text.length == 32').catch(err => console.log(err));

这基本上是此答案的副本:https://stackoverflow.com/a/46825433/10238810 除了我已更改querySelector,以查找具有类名称“ eo-validation-code”的元素。

1 个答案:

答案 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));