首页 > Web开发 > 详细

[Node.js] Take Screenshots of Multiple Dimensions for Responsive Sites using Nightmare

时间:2017-04-18 15:03:29      阅读:210      评论:0      收藏:0      [点我收藏+]

When developing responsive websites, you will constantly be resizing your browser to make sure your site is properly responding to all of the resizes. You can script this behavior by using Nightmare to leverage Electron and it will handle all the resizing for you. Nightmare can then also takes screenshots and save them so you can make sure the site matches your designs.

const Nightmare = require(‘nightmare‘);
const path = require(‘path‘);

const nightmare = new Nightmare({
    show: true,
    frame: false
                                });

nightmare
    .goto(‘https://egghead.io‘)
    .viewport(640, 480)
    .wait(1000)
    .screenshot(‘./screenshots/640x480.png‘)
    .viewport(1280, 720)
    .wait(1000)
    .screenshot(‘./screenshots/1280x720.png‘)
    .end()
    .then(() => console.log("done"));

 

Github

 

[Node.js] Take Screenshots of Multiple Dimensions for Responsive Sites using Nightmare

原文:http://www.cnblogs.com/Answer1215/p/6727838.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!