首页 > 代码库 > [Node.js] Take Screenshots of Multiple Dimensions for Responsive Sites using Nightmare
[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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。