page.evalute() does not work as described
See original GitHub issue- Puppeteer version: 0.13.0
- Platform / OS version: Sierra 10.12.6
- URLs (if applicable):
- Node.js version: v8.9.0
I am trying to create reference to a DOM element with page.evalute() like so:
const myElement = (await page.evaluate( () => {
let overflowDiv = document.querySelectorAll('.overflow')[0];
let buttonDiv = overflowDiv.children[1];
let listsButton = buttonDiv.children[0];
return listsButton;
}))();
await page.click(myElement);
However, I get a TypeError that myElement is not a function. According to the documentation it is supposed to resolve a promise. What am I dong wrong?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Puppeteer page.evaluate not working as expected
I have a console log before I run page.evaluate() which logs what I expect, but the console log inside page.evaluate never runs. const...
Read more >Page.evaluate() method - Puppeteer
Page.evaluate() method. Evaluates a function in the page's context and returns the result. If the function passed to page.evaluateHandle returns a Promise, ...
Read more >puppeteer.Page.evaluate JavaScript and Node.js ... - Tabnine
Evaluates a function in the browser context. If the function, passed to the frame.evaluate, returns a Promise, then frame.evaluate would wait for the...
Read more >Variable not defined with page.evaluate in Puppeteer - YouTube
Your browser can 't play this video. Learn more. Switch camera.
Read more >Puppeteer documentation - DevDocs
NOTE Puppeteer can also be used to control the Chrome browser, but it works best with the version of Chromium it is bundled...
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
@IgorDraskovic ah sorry, you should use
page.evaluateHandle
instead ofpage.evaluate
.@mdrazahassan plz file a separate issue.