Viff测试框架,它可以不同环境和浏览器下的Web页面的视觉差异。
示例代码:
var Viff = require('viff');var viff = new Viff('https://localhost:4444/wd/hub');viff.takeScreenshot('firefox', 'https://localhost:3000', '/path1', function (bufferImg) { /* buffer of images */ });// partial of web pagesviff.takeScreenshot('firefox', 'https://localhost:3000', ['path1', '#css-selecor'], function (bufferPartialImg) {});// responsive of web pagesfunction size(width) { return function (driver) { driver.setWindowSize(width, 600 /* any height*/); };}viff.takeScreenshot('firefox', 'https://localhost:3000', ['path', size(1024)], function (bufferImg) {});// Q promiseviff.takeScreenshot('firefox', 'https://localhost:3000', ['path', size(1024)]) .done(function (bufferImg) { /* generate image here */ }) .catch(function (err) { /* handle err here */ })// using browserstackviff = new Viff('https://hub.browserstack.com/wd/hub');viff.takeScreenshot({ 'browserName' : 'iPhone', 'platform' : 'MAC', 'device' : 'iPhone 5', 'browserstack.user': /* your name */, 'browserstack.key': /* your key */}, 'https://www.google.com', 'path1', function (bufferImg) {});
评论