-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Screenshot callback halts nightmare from advancing down the chain #934
Comments
Instead of specifying the 'done' callback exclusively, specify the path and a simple callback const path = '/some/path/someFileName.jpg';
nightmare.screenshot(path, () => console.log('screenshot taken')); Correct me if I'm wrong, but .end(), is also a thenable which you can use to do something like:
|
Please update me. I usually use async-await / generators for nightmareJS but I hope this works for you. |
|
@rosshinkley https://github.com/segmentio/nightmare/blob/master/lib/actions.js#L600 I think the current branch still does. It just isn't documented. The top level callback is bubbled down as a callback to fs.writeFile. |
@jekku I don't think that does what you think it does, and now that you've pointed it out, I think I see the problem. You can pass a function like that, but it will do exactly what @tlshaheen said - it will prevent downstream execution of the Nightmare chain. What that is looking for is the internal To make things clearer, an example might be helpful: nightmare.goto('http://www.example.org')
.screenshot((err, buf) => {
console.log('hello from screenshot callback');
// do something with the buffer
return "some value";
})
.end()
.then((something) => console.log(something)); This will print So while what i said is technically incorrect - For completeness, if you wanted the buffer, the above example is easily fixed: nightmare.goto('http://www.example.org')
.screenshot()
.end()
.then((buffer) => {
// do something with the buffer...
}); I'm still curious what version the original example was written against and/or where the example came from. |
Looks like this is resolved. I am going to close this for now but feel free to open a new issue if you are still having problems. |
I have an issue similar to #555, but I'm not sure it's the same cause so I'm opening a new issue. I'm using
nightmare v2.9.0
. When the following code runs, it takes the screenshot, and "screenshot taken" is loaded to the console - but the window is never closed,run()
is never called. If I enter a path likenightmare.png
instead of the callback, it works. But the callback seems to freeze Nightmare.Should I be returning something other than
true
from my callback, or calling another method inside myscreenshot()
callback to tell Nightmare to keep moving down the chain?I tried one suggestion from #555 but no dice.
My end goal from the screenshot callback is to save the screenshot to AWS S3, directly inside the callback. But the problem exists without even having any of the S3
putObject()
code in the callback.The text was updated successfully, but these errors were encountered: