Viff测试框架,它可以不同环境和浏览器下的Web页面的视觉差异。
示例代码:
var Viff = require('viff');var viff = ew Viff('https://localhost:4444/wd/hub');viff.takeScreeshot('firefox', 'https://localhost:3000', '/path1', fuctio (bufferImg) { /* buffer of images */ });// partial of web pagesviff.takeScreeshot('firefox', 'https://localhost:3000', ['path1', '#css-selecor'], fuctio (bufferPartialImg) {});// resposive of web pagesfuctio size(width) { retur fuctio (driver) { driver.setWidowSize(width, 600 /* ay height*/); };}viff.takeScreeshot('firefox', 'https://localhost:3000', ['path', size(1024)], fuctio (bufferImg) {});// Q promiseviff.takeScreeshot('firefox', 'https://localhost:3000', ['path', size(1024)]) .doe(fuctio (bufferImg) { /* geerate image here */ }) .catch(fuctio (err) { /* hadle err here */ })// usig browserstackviff = ew Viff('https://hub.browserstack.com/wd/hub');viff.takeScreeshot({ 'browserName' : 'iPhoe', 'platform' : 'MAC', 'device' : 'iPhoe 5', 'browserstack.user': /* your ame */, 'browserstack.key': /* your key */}, 'https://www.google.com', 'path1', fuctio (bufferImg) {});
评论