Make multiple screenshots with nightmare-screenshot-selector

Make multiple screenshots with nightmare-screenshot-selector

By : Rimal Mohan
Date : October 17 2020, 03:08 PM
will help you I inserted a .end() call, works for me. Slightly modified code, grabs two regions of Google home page:
code :
function savePicture(picture) {
    picture = ['div#hplogo', 'div.tsf-p'];
    let browser = Nightmare({
        show: false,
        webPreferences: {
            partition: 'nopersist'
    picture.forEach(v => {  
            .then(function (data) {                 
                fs.writeFileSync(`img/${v}.png`, data)
            .then(()=> {
            .catch((error) => {
                console.log('Error loading the page', error)

Share : facebook icon twitter icon
Screenshot app that can take screenshots in any view

Screenshot app that can take screenshots in any view

By : Sam
Date : March 29 2020, 07:55 AM
hop of those help? No, it's not possible to interact with other applications outside of your sandbox on iOS.
Make screenshot of all elements with the same selector on the page

Make screenshot of all elements with the same selector on the page

By : Amy Mondra
Date : March 29 2020, 07:55 AM
wish of those help Doing the same thing over and over again and expecting different results ... may happen in web browser testing, but not in this case. In this case you're repeating the same task over and over again with the same selector. You need to iterate over the selectors.
This will not work using CSS selectors because :nth-of-type() for example means the nth element under the same parent, which may not be the case for your site.
code :
var x = require('casper').selectXPath;
    var elements = this.getElementsInfo(".annotation"); // for correct count
    elements.forEach(function(_el, index){
        // don't need the element info, this was done just for count
        casper.captureSelector(Math.random()+"_"+index+".png", x("(//*[contains(@class,'annotation')])["+(index+1)+"]"));
CasperJS multiple capture screenshots: Latest screenshot overwrites all previous ojnes

CasperJS multiple capture screenshots: Latest screenshot overwrites all previous ojnes

By : Janie Rudloff
Date : March 29 2020, 07:55 AM
I hope this helps you . Figured out that I had overlapping event handlers on the "fail" event. To remedy this, changed my casperjs test style to include the test object with setUp and tearDown functions, removed the event handles by doing
casper.test.removeListener("fail", casper.test.listeners("fail")[0]);
Getting the Nightmare.JS (v 2.9.1) screenshot buffer

Getting the Nightmare.JS (v 2.9.1) screenshot buffer

By : Ouma Senior
Date : March 29 2020, 07:55 AM
wish of those help You are almost there: in your final .then(), e should be the completed buffer for the PNG. To verify, you can change the .then() function slightly:
code :
    function(e) {
      //this should print "e is a buffer: true"
      console.log(`e is a buffer: ${Buffer.isBuffer(e)}`);

      return nightmare.end()
        .then(function(result) {
          console.log('completed screenshot', result)
Nightmare.js screenshot buffer length 0

Nightmare.js screenshot buffer length 0

By : Miroslaw
Date : March 29 2020, 07:55 AM
hope this fix your issue Trying it from different flow, gave better results: The difference in approach is: first scroll to element and then take its bounds and then proceed for screenshot.
code :
const Nightmare = require('nightmare');
const fs = require('fs');
const nightmare = Nightmare({
  show: true,
  openDevTools: false,
  gotoTimeout: 45000

  .evaluate(getElements, 'div.g')
  .then(() => {
    console.log("Calling screenshots: ");
  .catch(function(err) {

function getAllScreenshots(index) {
  console.log("Called with index: ", index)
  nightmare.evaluate(function(index) {
      const r = Math.round;
      if(index >= window.__nightmare.output.length) {
        return false;
      var element = window.__nightmare.output[index];
      console.log(index, element.innerHTML);
      var bound = element.getBoundingClientRect();
      return {
        x: r(bound.left)-10,
        y: r(bound.top)-10,
        width: r(element.clientWidth)+40,
        height: r(element.clientHeight)+10
    }, index)
    .then(function(bound) {
      if(!bound) {
      console.log("Taking screenshot: ", bound);
      nightmare.wait(500).screenshot(__dirname + '/images/navbar' + index + '.png', bound)
        .then(function() {
          console.log("Calling Next of: ", index);
          getAllScreenshots(index + 1);
        }).catch(function(err) {
    .catch(function(err) {

function getElements(selector) {
  var elements = document.querySelectorAll(selector);
  window.__nightmare.output = elements;
Related Posts Related Posts :
  • How to change dynamic data-src for lazy images?
  • how to apply a filter for an attribute?
  • Redirect in JavaScript without losing the form post data
  • Uglify weird characters spaces
  • Ember not detecting all attributes from server response
  • convert axisX date to text in Html5 5 line chart
  • React. setState does not update state of subcomponents
  • Replace expression between two punctuation letters in javascript
  • FabricJS circle to show radius
  • How to delete the rows corresponding to the selected `yes` input?
  • Delete image on clicking "X" mark on right top of image
  • ternary operator does not change backgroundColor
  • How I can hide the root element in a dendogram d3
  • How to pass variables to a method inside a fuction JavaScript
  • $window.location.href (angular.js:12520 TypeError: Cannot set property 'href' of undefined)
  • How to use dynamic CSS
  • How do I return the static data?
  • How can i set a label text by a javascript function without knowing the label ID in javascript
  • Chrome extension form input text is blank on submit
  • Get specific key value in a string
  • Set CSS property with js click event handler
  • How to collect all array unique values from array of objects using underscore?
  • Polyfill to list the HTTP headers of a Header's instance
  • Checking if the input fields are filled in properly (pure javascript)
  • Replace an expression in string using javascript
  • Iterating for loop for set number of iterations each time it is called until the end of an array
  • How to use JQuery on a WordPress Page/Post
  • Angular Error: Unknown provider: dataserviceProvider
  • jQuery - Why it replaces the value twice?
  • Hide all countries list in a select dropdown and show only Belgium/BE using jquery
  • Skip jQuery validation when div element is hidden
  • Display time calculation in full format
  • How to rotate in 3D many rect in SVG with a different angle of rotation?
  • Datatables not working when loading specific page though id
  • ReactJS: How to rerender component after fetching data
  • In Mapbox how can you toggle layers from a style on iOS?
  • Could installing Dreamweaver affect how your browser runs scripts?
  • Detect virtual keyboard on screen and landscape orientation in javascript
  • JSON: Uncaught SyntaxError: missing ) after argument list
  • Trigger classList for * in JavaScript
  • jQuery function - set String parameter
  • Using associative arrays in javascript
  • Simple bar chart d3
  • How to get private variables from prototyped methods in Javascript
  • How do I route a string to a function based on a regex match?
  • Is it okay to add/remove classes in stateless react component
  • Jquery array loop
  • Toggle disabled attribute of paper-button
  • Ask user permission to expire the session
  • handle dojo EdgeToEdgeStoreList event
  • How to edit File in perfoce with node js?
  • What is the DOM event when slider button stops moving
  • Param as router - ExpressJS
  • How can I make my popup appear smoothly after 5 seconds?
  • Change type of paper-input programmatically
  • How to access results of a promise at a later part of a chain
  • Remove click function, but keep hover intact
  • What is it called when I can select a HTML element in JS using it's ID?
  • Deploy folder in CWD using Shipit JS
  • React: show object as working JS format?
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com