-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunner.js
More file actions
71 lines (66 loc) · 1.64 KB
/
Copy pathrunner.js
File metadata and controls
71 lines (66 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* global require, console */
console.log('----------- Pipter ----------');
console.log('Pixel Perfect Frontend Tester');
var _ = require('lodash');
var async = require('async');
var webdriverjs = require('webdriverjs-angular'),
client = webdriverjs.remote({
desiredCapabilities: {
browserName: 'chrome',
// chromeOptions: {
// args: ['no-startup-window']
// }
},
ngRoot: 'body'
});
var runner = function(force_state, cb) {
client
.init()
.setViewportSize({ width: 1280, height: 800 })
.url('http://localhost:8100')
.execute(function() {
var urls = [];
var $state = angular.element('body').injector().get('$state');
_.each($state.get(), function(state) {
if(!state.abstract) {
urls.push({
url: $state.href(state.name, {}, { absolute: true }),
name: state.name,
state: state
});
}
});
return urls;
}).then(function(response) {
var list = [];
console.log('got state', force_state);
if(force_state) {
list.push(_.find(response.value, function(state) {
if(state.name == force_state) {
return state;
}
}));
}
else {
list = response.value;
}
console.log('found', _.size(list), list, 'states');
async.forEachOfSeries(list, function(state, key, callback) {
console.log('create screenshot for', state.url+'...');
client
.url(state.url)
.saveScreenshot(__dirname + '/screenshots/current/'+state.name+'.png')
.then(function() {
console.log('done!');
callback();
});
}, function() {
console.log('okay, all done!');
client.end();
if(cb) {
cb();
}
});
});
};
module.exports = runner;