最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Puppeteer (Evaluation failed: syntaxerror: invalid or unexpcted token) - Stack Overflow

programmeradmin2浏览0评论

The error the following line:

await page.waitForFunction('document.querySelector(".eo-validation-code").inner‌​Text.length == 32');

Here it is in context:

    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('.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));

It's basically a copy paste of this answer: With the exception that I have changed the querySelector to find an element with the class name "eo-validation-code".

The error the following line:

await page.waitForFunction('document.querySelector(".eo-validation-code").inner‌​Text.length == 32');

Here it is in context:

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

It's basically a copy paste of this answer: https://stackoverflow./a/46825433/10238810 With the exception that I have changed the querySelector to find an element with the class name "eo-validation-code".

Share Improve this question asked Aug 20, 2018 at 20:16 Ryan CameronRyan Cameron 3712 gold badges5 silver badges16 bronze badges 1
  • By copying paste to Chrome console you will see .inner‌​..Textwhich means there are invisible characters between the inner and the Text. – Yami Odymel Commented Dec 8, 2020 at 18:34
Add a ment  | 

1 Answer 1

Reset to default 6

Something went wrong with your r symbol in innerText (i think it might be BOM)
Try it:

    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)); 
发布评论

评论列表(0)

  1. 暂无评论