New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
evaluate - strange execute sequence #324
Comments
Nice one, thanks for reporting it. @aslushnikov: this sounds like an argument towards support for objectHandles. |
@pavelfeldman ok I am stumped. What does this have to do with object handles? |
Joel: they would save us some round trips |
Ooooh |
@JoelEinbinder: it is essential that we emit events (not only console ones) in order. That way for the user script console.log(window);
document.body.offsetWidth;
console.log(document); we would get LOG, LAYOUT, LOG notifications in order. That means that you need to emit LOG ones immediately and the arguments of those events become lazily evaluated. Which is objectHandles. Not necessarily generically exposed via API at this point, but why exposing in an ad-hoc manner if we already need to deal with |
... or we introduce |
I was thinking we just make the values from console.log be promises. |
This can be fixed once #382 is done. |
This patch starts dispatching JSHandle instances as console arguments. BREAKING CHANGE: this changes the API of the ConsoleMessage. Fixes puppeteer#324.
This patch starts dispatching JSHandle instances as console arguments. BREAKING CHANGE: this changes the API of the ConsoleMessage. Fixes #324.
Soo, how are we supposed to get the console log messages now? According to https://github.com/GoogleChrome/puppeteerstill, this should work - but it doesn't. Edit: |
@thomas-darling I'm not sure I follow. Is the question "how do I use JSHandle"? |
Yeah, sorry for the less than clear question. Based on the documentation on the page I mentioned, I expected that line of code to forward the console log calls with the original arguments - but what I got in my console was a bunch of stringified What I was trying to achieve, was to simply get the original arguments for the console.log calls made by the page. Given that those arguments are now |
@thomas-darling ah I see. For logging, JSHandle's page.on('console', async msg => {
const jsonArgs = await Promise.all(msg.args.map(arg => arg.jsonValue()));
console.log('PAGE LOG:', ...jsonArgs);
}); Note: this might shuffle the log messages between each other because you If you need the order retained, you can retain it manually: let chain = Promise.resolve();
page.on('console', msg => {
chain = chain.then(async function() {
const jsonArgs = await Promise.all(msg.args.map(arg => arg.jsonValue()));
console.log('PAGE LOG:', ...jsonArgs);
});
}); |
scripts:
output:
The text was updated successfully, but these errors were encountered: