You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm kind of stuck on an issue and I'm not sure if I'm understanding the custom action or not. I'm running a nightmare.js script where where I'm trying to take a screenshot of multiple elements on a page.
The first element is captured just fine, but every other element that is below the fold is captured with a zero length. I am struggling to debug this issue. Any help would be incredibly appreciated.
Basically this script walks through a page and selects all the elements on the page that match a selector. Then, using async it collects the responses and returns a buffer of objects. The issue is that the elements below the fold do not get screenshotted (buffer length ends up at zero). I tried to wait() and scroll to the element, but I have not had any success as of yet.
The code is:
import*asNightmarefrom'nightmare'import*asvofrom'vo'import*asasyncfrom'async'import*asfsfrom'fs'consturls:String[]=['https://yahoo.com/']Nightmare.action('snap',function(selector:String,done:Function){constself=this;this.evaluate_now(function(selector){returnArray.from(document.querySelectorAll(selector)).map((ele:Element)=>{if(ele){constrect=ele.getBoundingClientRect()constr:Function=Math.roundreturn{x: r(rect.left),y: r(rect.top),width: r(rect.width),height: r(rect.height)}}})},function(err,clips){if(err)returndone(err)if(!clips)returndone(newError(`Selector not found`))letsnaps=[]constsnap=(clip,cb)=>{self.scrollTo(clip.y-clip.height,clip.x).screenshot(clip,cb).run()}async.mapSeries(clips.reverse(),snap,(err,res)=>{done(err,res)})},selector)})constscrape=(url)=>{constnightmare=Nightmare({show: true});nightmare.goto(url).snap('.navbar').end().then((buffers:Buffer[])=>{buffers.forEach((data,index)=>{fs.writeFileSync(`images/navbar-${index}.png`,data)})})}urls.forEach(scrape)
The text was updated successfully, but these errors were encountered:
auser
changed the title
screenshot buffer length of 0 when taking multiple screenshots in custom action
screenshots zero-length when taking multiple screenshots in custom action (empty screenshots)
Jun 16, 2017
I wanted to leave a little note here that I had this same issue while running nightmare in docker and was able to google enough to find that the docker shared memory is 64mb by default and is the cause of this and a few other things changing it to 128mb fixed it but you may need more or less I submitted #1570 to add more info onto the readme.
I'm kind of stuck on an issue and I'm not sure if I'm understanding the custom action or not. I'm running a nightmare.js script where where I'm trying to take a screenshot of multiple elements on a page.
The first element is captured just fine, but every other element that is below the fold is captured with a zero length. I am struggling to debug this issue. Any help would be incredibly appreciated.
Basically this script walks through a page and selects all the elements on the page that match a selector. Then, using async it collects the responses and returns a buffer of objects. The issue is that the elements below the fold do not get screenshotted (buffer length ends up at zero). I tried to wait() and scroll to the element, but I have not had any success as of yet.
The code is:
(I've also posted this on stackoverflow here
The text was updated successfully, but these errors were encountered: