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

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Node.js] Take Screenshots of Multiple Dimensions for Responsive Sites using Nightmare相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

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

如何使用猎犬/ elixir进行屏幕截图

vbs 截图

ride关键字

Python + Appium 获取当前屏幕的截图方法的封装

带有 react-native 的编程式屏幕触摸