Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
539 views
in Technique[技术] by (71.8m points)

node.js - debug in chromium / puppeteer doesn't populate evaluate script

So I have the following code launching

this.browser = await puppeteer.launch( { headless: false, devtools: true, slowMo: 200});
this.page = await this.browser.newPage();

await this.page.goto(pageUrl);

let result = await this.page.evaluate(() => {
            const labels = document.querySelectorAll("li.product-item");

            let productList = [];

            for(let product of labels) {
                productList.push(product);
            }
            debugger;

            //filter only product stacks that have a price
            const productStacks = productList.filter(product => product.querySelector("span.price-wrapper") !== null);

            let results = productStacks.map(product => {
                return product.querySelector("span.price-wrapper").getAttribute("data-price-amount");
            });

            return results;
        });

So chromium starts up and pauses at the appropriate code (as best as I can tell), I can even see the local variables populate with the expect result and step through the code, however the open file puppeteer_evaluation_script is not populated with the evaluation script and remains with the contents, so I'm stepping through blind.

//# sourceURL=__puppeteer_evaluation_script__

Occasionally after many minutes it sometimes does actually populate with the code. I have no idea what's wrong, I've tried updating the latest node lts and puppeteer but have the same behavior.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...