chrome中,BackstopJS 使用cookie文件后依旧提示需要登录
1. 本地环境:
apache-tomcat:7.05,jdk8, backstopJS:latest-version
配置tomcat管理用户成功;手工访问tomcat应用内部服务正常;
2. 问题现象:
使用chrome时,在cookie.json中添加浏览器cookie后,使用reference 命令,无法正常截图,浏览器卡在输入tomcat用户名密码界面。设置cookie无效。
3. 问题解决:
backstop_data -> engine_script -> chromy -> loadCookie.js中,将cookie.url 赋值方式设置为http :
var fs = require('fs');
module.exports = function (chromy, scenario) {
var cookies = [];
var cookiePath = scenario.cookiePath;
// READ COOKIES FROM FILE IF EXISTS
if (fs.existsSync(cookiePath)) {
cookies = JSON.parse(fs.readFileSync(cookiePath));
}
// MUNGE COOKIE DOMAIN FOR CHROMY USAGE
cookies = cookies.map(cookie => {
//cookie.url = 'https://' + cookie.domain;
cookie.url = 'http://' + cookie.domain;
delete cookie.domain;
return cookie;
});
// SET COOKIES VIA CHROMY
chromy.setCookie(cookies);
console.log('Cookie state restored with:', JSON.stringify(cookies, null, 2));
};
4. 问题原帖:
https://github.com/garris/BackstopJS/issues/688