page.evalute doesn't seem to work in version 0.13.0
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 0.13.0
- Platform / OS version: macPS Sierra version 10.12.6
What steps will reproduce the problem?
await page.goto(`${opts.appUrl}#${opts.localToken}`, {waitUntil: 'networkidle0'});
const header = await page.evaluate(() => {
const element = document.getElementsByClassName('header');
console.log(element);
return element;
});
console.log(header)
What is the expected result? I have an almost empty page with a header. If I run the following code the element is logged to the console in the browser in the page.evaluate function. However the next console.log is undefined. I expected it to be the same.
If I run this code in version 0.10.2 it works.
await page.goto(`${opts.appUrl}#${opts.localToken}`, {waitUntil: 'networkidle'});
const header = await page.evaluate(() => {
const element = document.getElementsByClassName('header');
console.log(element);
return element;
});
console.log(header)
The only difference is that networkidle is replaced with networkidle0
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Puppeteer page.evaluate not working as expected
The code inside page.evaluate is run in the browser context, so the console.log works, but inside the Chrome console and not the Puppeteer ......
Read more >Puppeteer API v0.13.0 - 作业部落
This method fetches an element with selector , scrolls it into view if needed, and then uses page.mouse to hover over the center...
Read more >page-evaluate - npm
Monitor web pages for changes. Latest version: 1.1.0, last published: a month ago. Start using page-evaluate in your project by running `npm ...
Read more >/vendor/puppeteer/docs/api.md | puppeteer_plus@0.12.0 | Deno
When installed, it downloads a version ofChromium, which it then drives using `puppeteer-core`. Being an end-user product, `puppeteer` supports a bunch of ...
Read more >Changelog — great_expectations documentation
[DOCS] doc-297: update the create Expectations overview page for Data Assistants ... [BUGFIX] fixed a bug where expectation metadata doesn't appear in edit ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There were some changes in result serialization before the 0.13. You can try this:
I think
document.getElementsByClassName('header');
should bedocument.getElementsByClassName('header')[0];
ordocument.querySelector(".header"))
, else renameconst element
toconst elements
. See this SO answer which uses the same code.