wraith 2.5.2 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +17 -14
- data/{templates/configs → configs/templates}/component.yaml +10 -6
- data/{templates/configs → configs/templates}/config.yaml +2 -2
- data/configs/test_config--casper.yaml +29 -0
- data/lib/wraith/cli.rb +6 -5
- data/lib/wraith/javascript/beforeCapture.js +5 -0
- data/lib/wraith/javascript/casper.js +34 -6
- data/lib/wraith/save_images.rb +13 -13
- data/lib/wraith/version.rb +1 -1
- data/lib/wraith/wraith.rb +4 -0
- data/spec/base/global.png +0 -0
- data/spec/base/path.png +0 -0
- data/spec/helpers.rb +22 -0
- data/spec/js/global.js +6 -0
- data/spec/js/path.js +6 -0
- data/spec/wraith_spec.rb +34 -14
- data/wraith-logo.png +0 -0
- data/wraith.gemspec +2 -2
- metadata +19 -7
- data/configs/config.yaml +0 -41
- data/templates/javascript/casper.js +0 -25
- data/templates/javascript/snap.js +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc02a9bdf3aceb57ec1790b0670454646ac9adbf
|
4
|
+
data.tar.gz: 4d9267de7cb2689b6bb01129fc4f25dbfd76c89e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 883098ff0a08426b8532e29491580ad14ef854777acea133a3da71f25b442e92b65688718bea5e18c5d2db5caa6e4151706c1b29d3cf41eee4c55be0ed905cc1
|
7
|
+
data.tar.gz: 4899954af25ca0b3645dada0519c09c22a97547a6283fe674f67cf580438bf726f248c225b7cc0b5b8013336b4e6070ffc50f2cba8df5177a5b501dd3ccc61e4
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
<p align="center">
|
2
|
+
<img src="https://raw.githubusercontent.com/BBC-News/wraith/master/wraith-logo.png">
|
3
|
+
</p>
|
4
|
+
|
5
|
+
<p align="center">
|
6
|
+
<a href="http://travis-ci.org/BBC-News/wraith" target="_blank"><img src="https://secure.travis-ci.org/BBC-News/wraith.png?branch=master"></a>
|
7
|
+
<a href="https://rubygems.org/gems/wraith" target="_blank"><img src="https://img.shields.io/gem/v/wraith.svg"></a>
|
8
|
+
<a href="https://codeclimate.com/github/BBC-News/wraith" target="_blank"><img src="https://codeclimate.com/github/BBC-News/wraith.png"></a>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p align="center">
|
12
|
+
Wraith is a screenshot comparison tool, created by developers at BBC News.
|
13
|
+
<br>
|
14
|
+
<a href="http://responsivenews.co.uk" target="_blank">Website</a> • <a href="http://github.com/bbc-news/wraith" target="_blank">Source</a>
|
15
|
+
</p>
|
13
16
|
|
14
17
|
## What is it?
|
15
18
|
|
@@ -31,7 +34,7 @@ diff](http://bbc-news.github.io/wraith/img/wraith.png)
|
|
31
34
|
Imagemagick and PhantomJS are required to use Wraith, install via your favourite package manager. You can also use SlimerJS and CasperJS, CasperJS can be used to target specific selectors. To read our detailed instructions for setup and install, as well as example configs, visit [wraith docs](http://bbc-news.github.io/wraith/index.html)
|
32
35
|
|
33
36
|
```sh
|
34
|
-
brew install phantomjs
|
37
|
+
brew install phantomjs
|
35
38
|
brew install imagemagick
|
36
39
|
```
|
37
40
|
|
@@ -60,7 +63,7 @@ wraith setup
|
|
60
63
|
|
61
64
|
### CLI
|
62
65
|
|
63
|
-
There are other commands also available, these all expect a config_name to be passed as an option. Wraith will look for the config file at `configs/[config_name].yaml`.
|
66
|
+
There are other commands also available, these all expect a config_name to be passed as an option. Wraith will look for the config file at `configs/[config_name].yaml`.
|
64
67
|
|
65
68
|
```sh
|
66
69
|
wraith capture [config_name] # A full Wraith job
|
@@ -8,11 +8,11 @@ snap_file: "javascript/casper.js"
|
|
8
8
|
|
9
9
|
# Type the name of the directory that shots will be stored in
|
10
10
|
directory: 'shots'
|
11
|
+
history_dir: 'shots_base'
|
11
12
|
|
12
|
-
# Add
|
13
|
+
# Add as many domains as necessary. Key will act as a label
|
13
14
|
domains:
|
14
|
-
|
15
|
-
arabic: "http://www.bbc.com/arabic"
|
15
|
+
english: "http://www.bbc.co.uk/news"
|
16
16
|
|
17
17
|
#Type screen widths below, here are a couple of examples
|
18
18
|
screen_widths:
|
@@ -24,9 +24,13 @@ screen_widths:
|
|
24
24
|
|
25
25
|
#Type page URL paths below, here are a couple of examples
|
26
26
|
paths:
|
27
|
-
|
28
|
-
path: /
|
29
|
-
selector: '.
|
27
|
+
clickable_guide:
|
28
|
+
path: /entertainment-arts-27221191
|
29
|
+
selector: '.idt__news'
|
30
|
+
clickable_guide__after_click:
|
31
|
+
path: /entertainment-arts-27221191
|
32
|
+
selector: '.idt__news'
|
33
|
+
before_capture: 'javascript/beforeCapture.js'
|
30
34
|
|
31
35
|
#Amount of fuzz ImageMagick will use
|
32
36
|
fuzz: '20%'
|
@@ -11,7 +11,7 @@ directory: 'shots'
|
|
11
11
|
|
12
12
|
# Add only 2 domains, key will act as a label
|
13
13
|
domains:
|
14
|
-
|
14
|
+
arabic: "http://www.live.bbc.co.uk/arabic"
|
15
15
|
russian: "http://www.live.bbc.co.uk/russian"
|
16
16
|
|
17
17
|
#Type screen widths below, here are a couple of examples
|
@@ -25,7 +25,7 @@ screen_widths:
|
|
25
25
|
#Type page URL paths below, here are a couple of examples
|
26
26
|
paths:
|
27
27
|
home: /
|
28
|
-
uk_index: /
|
28
|
+
uk_index: /topics/video
|
29
29
|
|
30
30
|
#Amount of fuzz ImageMagick will use
|
31
31
|
fuzz: '20%'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#Headless browser option
|
2
|
+
browser:
|
3
|
+
phantomjs: "casperjs"
|
4
|
+
# slimerjs: "slimerjs"
|
5
|
+
|
6
|
+
#If you want to have multiple snapping files, set the file name here
|
7
|
+
snap_file: "lib/wraith/javascript/casper.js"
|
8
|
+
|
9
|
+
# Type the name of the directory that shots will be stored in
|
10
|
+
directory: 'shots'
|
11
|
+
|
12
|
+
# Add only 2 domains, key will act as a label
|
13
|
+
domains:
|
14
|
+
afrique: "http://www.bbc.com/afrique"
|
15
|
+
russian: "http://www.bbc.com/russian"
|
16
|
+
|
17
|
+
#Type screen widths below, here are a couple of examples
|
18
|
+
screen_widths:
|
19
|
+
- 320
|
20
|
+
- 600
|
21
|
+
- 1280
|
22
|
+
|
23
|
+
#Type page URL paths below, here are a couple of examples
|
24
|
+
paths:
|
25
|
+
home: /
|
26
|
+
uk_index: /uk
|
27
|
+
|
28
|
+
#Amount of fuzz ImageMagick will use
|
29
|
+
fuzz: '20%'
|
data/lib/wraith/cli.rb
CHANGED
@@ -14,19 +14,20 @@ class Wraith::CLI < Thor
|
|
14
14
|
attr_accessor :config_name
|
15
15
|
|
16
16
|
def self.source_root
|
17
|
-
File.expand_path("../../../
|
17
|
+
File.expand_path("../../../", __FILE__)
|
18
18
|
end
|
19
19
|
|
20
20
|
desc "setup", "creates config folder and default config"
|
21
21
|
def setup
|
22
|
-
template("configs/config.yaml", "configs/config.yaml")
|
23
|
-
template("javascript/snap.js", "javascript/snap.js")
|
22
|
+
template("configs/templates/config.yaml", "configs/config.yaml")
|
23
|
+
template("lib/wraith/javascript/snap.js", "javascript/snap.js")
|
24
24
|
end
|
25
25
|
|
26
26
|
desc "setup_casper", "creates config folder and default config for casper"
|
27
27
|
def setup_casper
|
28
|
-
template("configs/component.yaml", "configs/component.yaml")
|
29
|
-
template("javascript/casper.js", "javascript/casper.js")
|
28
|
+
template("configs/templates/component.yaml", "configs/component.yaml")
|
29
|
+
template("lib/wraith/javascript/casper.js", "javascript/casper.js")
|
30
|
+
template("lib/wraith/javascript/beforeCapture.js", "javascript/beforeCapture.js")
|
30
31
|
end
|
31
32
|
|
32
33
|
desc "reset_shots [config_name]", "removes all the files in the shots folder"
|
@@ -7,14 +7,42 @@ var url = casper.cli.get(0);
|
|
7
7
|
var view_port_width = casper.cli.get(1);
|
8
8
|
var image_name = casper.cli.get(2);
|
9
9
|
var selector = casper.cli.get(3);
|
10
|
+
var globalBeforeCaptureJS = casper.cli.get(4);
|
11
|
+
var pathBeforeCaptureJS = casper.cli.get(5);
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
this.
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
function snap() {
|
14
|
+
if (selector == undefined) {
|
15
|
+
this.capture(image_name);
|
16
|
+
}
|
17
|
+
else {
|
18
|
+
this.captureSelector(image_name, selector);
|
19
|
+
}
|
20
|
+
console.log('Snapping ' + url + ' at width ' + view_port_width);
|
21
|
+
}
|
22
|
+
|
23
|
+
casper.start();
|
24
|
+
casper.open(url);
|
25
|
+
casper.viewport(view_port_width, 1500);
|
26
|
+
casper.then(function() {
|
27
|
+
if (globalBeforeCaptureJS) {
|
28
|
+
require('./' + globalBeforeCaptureJS)(this);
|
29
|
+
}
|
30
|
+
});
|
31
|
+
casper.then(function() {
|
32
|
+
if (pathBeforeCaptureJS) {
|
33
|
+
require('./' + pathBeforeCaptureJS)(this);
|
34
|
+
}
|
35
|
+
});
|
36
|
+
// waits for all images to download before taking screenshots
|
37
|
+
// (broken images are a big cause of Wraith failures!)
|
38
|
+
// Credit: http://reff.it/8m3HYP
|
39
|
+
casper.waitFor(function() {
|
40
|
+
return this.evaluate(function() {
|
41
|
+
var images = document.getElementsByTagName('img');
|
42
|
+
return Array.prototype.every.call(images, function(i) { return i.complete; });
|
17
43
|
});
|
44
|
+
}, function then () {
|
45
|
+
snap.bind(this)();
|
18
46
|
});
|
19
47
|
|
20
48
|
casper.run();
|
data/lib/wraith/save_images.rb
CHANGED
@@ -29,23 +29,23 @@ class Wraith::SaveImages
|
|
29
29
|
base_file_name = meta.file_names(width, label, meta.base_label)
|
30
30
|
compare_file_name = meta.file_names(width, label, meta.compare_label)
|
31
31
|
|
32
|
-
jobs << [label, settings.path, width, settings.base_url, base_file_name, settings.selector]
|
33
|
-
jobs << [label, settings.path, width, settings.compare_url, compare_file_name, settings.selector] unless settings.compare_url.nil?
|
32
|
+
jobs << [label, settings.path, width, settings.base_url, base_file_name, settings.selector, wraith.before_capture, settings.before_capture]
|
33
|
+
jobs << [label, settings.path, width, settings.compare_url, compare_file_name, settings.selector, wraith.before_capture, settings.before_capture] unless settings.compare_url.nil?
|
34
34
|
end
|
35
35
|
end
|
36
36
|
parallel_task(jobs)
|
37
37
|
end
|
38
38
|
|
39
|
-
def capture_page_image(browser, url, width, file_name, selector)
|
40
|
-
puts `"#{browser}" #{wraith.phantomjs_options} "#{wraith.snap_file}" "#{url}" "#{width}" "#{file_name}" "#{selector}"`
|
39
|
+
def capture_page_image(browser, url, width, file_name, selector, global_before_capture, path_before_capture)
|
40
|
+
puts `"#{browser}" #{wraith.phantomjs_options} "#{wraith.snap_file}" "#{url}" "#{width}" "#{file_name}" "#{selector}" "#{global_before_capture}" "#{path_before_capture}"`
|
41
41
|
end
|
42
42
|
|
43
43
|
private
|
44
44
|
|
45
45
|
def parallel_task(jobs)
|
46
|
-
Parallel.each(jobs, :in_threads => 8) do |_label, _path, width, url, filename, selector|
|
46
|
+
Parallel.each(jobs, :in_threads => 8) do |_label, _path, width, url, filename, selector, global_before_capture, path_before_capture|
|
47
47
|
begin
|
48
|
-
attempt_image_capture(width, url, filename, selector, 5)
|
48
|
+
attempt_image_capture(width, url, filename, selector, global_before_capture, path_before_capture, 5)
|
49
49
|
rescue => e
|
50
50
|
puts e
|
51
51
|
create_invalid_image(filename, width)
|
@@ -53,9 +53,9 @@ class Wraith::SaveImages
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def attempt_image_capture(width, url, filename, selector, max_attempts)
|
56
|
+
def attempt_image_capture(width, url, filename, selector, global_before_capture, path_before_capture, max_attempts)
|
57
57
|
max_attempts.times do |i|
|
58
|
-
capture_page_image meta.engine, url, width, filename, selector
|
58
|
+
capture_page_image meta.engine, url, width, filename, selector, global_before_capture, path_before_capture
|
59
59
|
|
60
60
|
return if File.exist? filename
|
61
61
|
|
@@ -91,7 +91,11 @@ class CaptureOptions
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def selector
|
94
|
-
|
94
|
+
options["selector"] || " "
|
95
|
+
end
|
96
|
+
|
97
|
+
def before_capture
|
98
|
+
options["before_capture"] || "false"
|
95
99
|
end
|
96
100
|
|
97
101
|
def base_url
|
@@ -113,10 +117,6 @@ class CaptureOptions
|
|
113
117
|
def has_casper(options)
|
114
118
|
options["path"] ? options["path"] : options
|
115
119
|
end
|
116
|
-
|
117
|
-
def casper_selector(options)
|
118
|
-
options["selector"] ? options["selector"] : " "
|
119
|
-
end
|
120
120
|
end
|
121
121
|
|
122
122
|
class SaveMetadata
|
data/lib/wraith/version.rb
CHANGED
data/lib/wraith/wraith.rb
CHANGED
Binary file
|
data/spec/base/path.png
ADDED
Binary file
|
data/spec/helpers.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
def create_diff_image
|
2
|
+
wraith.engine.each do |_type, engine|
|
3
|
+
saving.capture_page_image(engine, test_url1, 320, test_image1, selector, 'false', 'false')
|
4
|
+
saving.capture_page_image(engine, test_url2, 320, test_image2, selector, 'false', 'false')
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def crop_images
|
9
|
+
Wraith::CropImages.new(config_name).crop_images
|
10
|
+
end
|
11
|
+
|
12
|
+
def compare_images
|
13
|
+
Wraith::CompareImages.new(config_name).compare_task(test_image1, test_image2, diff_image, data_txt)
|
14
|
+
end
|
15
|
+
|
16
|
+
def run_js_then_capture(config)
|
17
|
+
generated_image = 'shots/test/temporary_jsified_image.png'
|
18
|
+
saving.capture_page_image('casperjs', test_url1, 320, generated_image, selector, config[:global_js], config[:path_js])
|
19
|
+
Wraith::CompareImages.new(config_name).compare_task(generated_image, config[:output_should_look_like], diff_image, data_txt)
|
20
|
+
diff = File.open('shots/test/test.txt', "rb").read
|
21
|
+
expect(diff).to eq '0.0'
|
22
|
+
end
|
data/spec/js/global.js
ADDED
data/spec/js/path.js
ADDED
data/spec/wraith_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rspec"
|
2
2
|
require "image_size"
|
3
|
+
require "helpers"
|
3
4
|
require "./lib/wraith/cli"
|
4
5
|
|
5
6
|
describe Wraith do
|
@@ -68,7 +69,7 @@ describe Wraith do
|
|
68
69
|
|
69
70
|
it "saves image" do
|
70
71
|
wraith.engine.each do |_type, engine|
|
71
|
-
saving.capture_page_image(engine, test_url1, 320, test_image1, selector)
|
72
|
+
saving.capture_page_image(engine, test_url1, 320, test_image1, selector, 'false', 'false')
|
72
73
|
end
|
73
74
|
|
74
75
|
expect(image_size[0]).to eq 320
|
@@ -87,7 +88,7 @@ describe Wraith do
|
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
90
|
-
describe "When generating
|
91
|
+
describe "When generating thumbnails" do
|
91
92
|
it "produce thumbnails" do
|
92
93
|
create_diff_image
|
93
94
|
crop_images
|
@@ -99,19 +100,38 @@ describe Wraith do
|
|
99
100
|
expect(File).to exist("shots/thumbnails/test/test_diff.png")
|
100
101
|
end
|
101
102
|
end
|
102
|
-
end
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
saving.
|
107
|
-
|
108
|
-
|
109
|
-
|
104
|
+
describe "When hooking into beforeCapture" do
|
105
|
+
let(:config_name) { "test_config--casper" }
|
106
|
+
let(:saving) { Wraith::SaveImages.new(config_name) }
|
107
|
+
let(:wraith) { Wraith::Wraith.new(config_name) }
|
108
|
+
let(:selector) { "body" }
|
109
|
+
let(:before_suite_js) { "spec/js/global.js" }
|
110
|
+
let(:before_capture_js) { "spec/js/path.js" }
|
111
|
+
|
112
|
+
it "Executes the global JS before capturing" do
|
113
|
+
run_js_then_capture(
|
114
|
+
global_js: before_suite_js,
|
115
|
+
path_js: 'false',
|
116
|
+
output_should_look_like: 'spec/base/global.png'
|
117
|
+
)
|
118
|
+
end
|
110
119
|
|
111
|
-
|
112
|
-
|
113
|
-
|
120
|
+
it "Executes the path-level JS before capturing" do
|
121
|
+
run_js_then_capture(
|
122
|
+
global_js: 'false',
|
123
|
+
path_js: before_capture_js,
|
124
|
+
output_should_look_like: 'spec/base/path.png'
|
125
|
+
)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "Executes the global JS before the path-level JS" do
|
129
|
+
run_js_then_capture(
|
130
|
+
global_js: before_suite_js,
|
131
|
+
path_js: before_capture_js,
|
132
|
+
output_should_look_like: 'spec/base/path.png'
|
133
|
+
)
|
134
|
+
end
|
135
|
+
end
|
114
136
|
|
115
|
-
def compare_images
|
116
|
-
Wraith::CompareImages.new(config_name).compare_task(test_image1, test_image2, diff_image, data_txt)
|
117
137
|
end
|
data/wraith-logo.png
ADDED
Binary file
|
data/wraith.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'wraith/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'wraith'
|
8
8
|
spec.version = Wraith::VERSION
|
9
|
-
spec.authors = ['Dave Blooman', 'Simon Thulbourn']
|
10
|
-
spec.email = ['david.blooman@gmail.com', 'simon+github@thulbourn.com']
|
9
|
+
spec.authors = ['Dave Blooman', 'Simon Thulbourn', 'Chris Ashton']
|
10
|
+
spec.email = ['david.blooman@gmail.com', 'simon+github@thulbourn.com', 'chrisashtonweb@gmail.com']
|
11
11
|
spec.summary = 'Wraith is a screenshot comparison tool, created by developers at BBC News.'
|
12
12
|
spec.description = 'Wraith is a screenshot comparison tool, created by developers at BBC News.'
|
13
13
|
spec.homepage = 'https://github.com/BBC-News/wraith'
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wraith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Blooman
|
8
8
|
- Simon Thulbourn
|
9
|
+
- Chris Ashton
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2015-
|
13
|
+
date: 2015-08-20 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: pry
|
@@ -170,6 +171,7 @@ description: Wraith is a screenshot comparison tool, created by developers at BB
|
|
170
171
|
email:
|
171
172
|
- david.blooman@gmail.com
|
172
173
|
- simon+github@thulbourn.com
|
174
|
+
- chrisashtonweb@gmail.com
|
173
175
|
executables:
|
174
176
|
- wraith
|
175
177
|
extensions: []
|
@@ -188,10 +190,12 @@ files:
|
|
188
190
|
- assets/invalid.jpg
|
189
191
|
- bin/wraith
|
190
192
|
- configs/component.yaml
|
191
|
-
- configs/config.yaml
|
192
193
|
- configs/config_nojs.yaml
|
193
194
|
- configs/custom_height.yaml
|
194
195
|
- configs/history.yaml
|
196
|
+
- configs/templates/component.yaml
|
197
|
+
- configs/templates/config.yaml
|
198
|
+
- configs/test_config--casper.yaml
|
195
199
|
- configs/test_config.yaml
|
196
200
|
- lib/wraith.rb
|
197
201
|
- lib/wraith/cli.rb
|
@@ -200,6 +204,7 @@ files:
|
|
200
204
|
- lib/wraith/folder.rb
|
201
205
|
- lib/wraith/gallery.rb
|
202
206
|
- lib/wraith/gallery_template/gallery_template.erb
|
207
|
+
- lib/wraith/javascript/beforeCapture.js
|
203
208
|
- lib/wraith/javascript/casper.js
|
204
209
|
- lib/wraith/javascript/customHeight.js
|
205
210
|
- lib/wraith/javascript/nojs.js
|
@@ -209,11 +214,13 @@ files:
|
|
209
214
|
- lib/wraith/thumbnails.rb
|
210
215
|
- lib/wraith/version.rb
|
211
216
|
- lib/wraith/wraith.rb
|
217
|
+
- spec/base/global.png
|
218
|
+
- spec/base/path.png
|
219
|
+
- spec/helpers.rb
|
220
|
+
- spec/js/global.js
|
221
|
+
- spec/js/path.js
|
212
222
|
- spec/wraith_spec.rb
|
213
|
-
-
|
214
|
-
- templates/configs/config.yaml
|
215
|
-
- templates/javascript/casper.js
|
216
|
-
- templates/javascript/snap.js
|
223
|
+
- wraith-logo.png
|
217
224
|
- wraith.gemspec
|
218
225
|
homepage: https://github.com/BBC-News/wraith
|
219
226
|
licenses:
|
@@ -240,4 +247,9 @@ signing_key:
|
|
240
247
|
specification_version: 4
|
241
248
|
summary: Wraith is a screenshot comparison tool, created by developers at BBC News.
|
242
249
|
test_files:
|
250
|
+
- spec/base/global.png
|
251
|
+
- spec/base/path.png
|
252
|
+
- spec/helpers.rb
|
253
|
+
- spec/js/global.js
|
254
|
+
- spec/js/path.js
|
243
255
|
- spec/wraith_spec.rb
|
data/configs/config.yaml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#Headless browser option
|
2
|
-
browser:
|
3
|
-
phantomjs: "phantomjs"
|
4
|
-
# slimerjs: "slimerjs"
|
5
|
-
|
6
|
-
#If you want to have multiple snapping files, set the file name here
|
7
|
-
snap_file: "lib/wraith/javascript/snap.js"
|
8
|
-
|
9
|
-
# Type the name of the directory that shots will be stored in
|
10
|
-
directory: 'shots'
|
11
|
-
|
12
|
-
# Add only 2 domains, key will act as a label
|
13
|
-
domains:
|
14
|
-
arabic: "http://www.bbc.com/arabic"
|
15
|
-
russian: "http://www.bbc.com/russian"
|
16
|
-
|
17
|
-
#Type screen widths below, here are a couple of examples
|
18
|
-
screen_widths:
|
19
|
-
- 320
|
20
|
-
- 600
|
21
|
-
- 768
|
22
|
-
- 1024
|
23
|
-
- 1280
|
24
|
-
|
25
|
-
#Type page URL paths below, here are a couple of examples
|
26
|
-
paths:
|
27
|
-
home: /
|
28
|
-
uk_index: /uk
|
29
|
-
|
30
|
-
#Amount of fuzz ImageMagick will use
|
31
|
-
fuzz: '20%'
|
32
|
-
|
33
|
-
#Set the number of days to keep the site spider file
|
34
|
-
spider_days:
|
35
|
-
- 10
|
36
|
-
|
37
|
-
#Choose how results are displayed, by default alphanumeric. Different screen widths are always grouped.
|
38
|
-
#alphanumeric - all paths (with, and without, a difference) are shown, sorted by path
|
39
|
-
#diffs_first - all paths (with, and without, a difference) are shown, sorted by difference size (largest first)
|
40
|
-
#diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
|
41
|
-
#mode: diffs_first
|
@@ -1,25 +0,0 @@
|
|
1
|
-
var system = require('system');
|
2
|
-
var page = require('webpage').create();
|
3
|
-
var fs = require('fs');
|
4
|
-
var casper = require("casper").create();
|
5
|
-
|
6
|
-
var url = casper.cli.get(0);
|
7
|
-
var view_port_width = casper.cli.get(1);
|
8
|
-
var image_name = casper.cli.get(2);
|
9
|
-
var selector = casper.cli.get(3);
|
10
|
-
|
11
|
-
casper.start(url, function() {
|
12
|
-
this.viewport(view_port_width, 1500).then(function(){
|
13
|
-
this.wait(2000, function() {
|
14
|
-
if (selector == undefined) {
|
15
|
-
this.capture(image_name);
|
16
|
-
}
|
17
|
-
else {
|
18
|
-
this.captureSelector(image_name, selector);
|
19
|
-
}
|
20
|
-
console.log('Snapping ' + url + ' at width ' + view_port_width);
|
21
|
-
});
|
22
|
-
});
|
23
|
-
});
|
24
|
-
|
25
|
-
casper.run();
|
@@ -1,85 +0,0 @@
|
|
1
|
-
var system = require('system');
|
2
|
-
var page = require('webpage').create();
|
3
|
-
var fs = require('fs');
|
4
|
-
|
5
|
-
if (system.args.length === 3) {
|
6
|
-
console.log('Usage: snap.js <some URL> <view port width> <target image name>');
|
7
|
-
phantom.exit();
|
8
|
-
}
|
9
|
-
|
10
|
-
var url = system.args[1];
|
11
|
-
var image_name = system.args[3];
|
12
|
-
var view_port_width = system.args[2];
|
13
|
-
var current_requests = 0;
|
14
|
-
var last_request_timeout;
|
15
|
-
var final_timeout;
|
16
|
-
|
17
|
-
|
18
|
-
page.viewportSize = { width: view_port_width, height: 1500};
|
19
|
-
page.settings = { loadImages: true, javascriptEnabled: true };
|
20
|
-
|
21
|
-
// If you want to use additional phantomjs commands, place them here
|
22
|
-
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.17';
|
23
|
-
|
24
|
-
// You can place custom headers here, example below.
|
25
|
-
// page.customHeaders = {
|
26
|
-
|
27
|
-
// 'X-Candy-OVERRIDE': 'https://api.live.bbc.co.uk/'
|
28
|
-
|
29
|
-
// };
|
30
|
-
|
31
|
-
// If you want to set a cookie, just add your details below in the following way.
|
32
|
-
|
33
|
-
// phantom.addCookie({
|
34
|
-
// 'name': 'ckns_policy',
|
35
|
-
// 'value': '111',
|
36
|
-
// 'domain': '.bbc.co.uk'
|
37
|
-
// });
|
38
|
-
// phantom.addCookie({
|
39
|
-
// 'name': 'locserv',
|
40
|
-
// 'value': '1#l1#i=6691484:n=Oxford+Circus:h=e@w1#i=8:p=London@d1#1=l:2=e:3=e:4=2@n1#r=40',
|
41
|
-
// 'domain': '.bbc.co.uk'
|
42
|
-
// });
|
43
|
-
|
44
|
-
page.onResourceRequested = function(req) {
|
45
|
-
current_requests += 1;
|
46
|
-
};
|
47
|
-
|
48
|
-
page.onResourceReceived = function(res) {
|
49
|
-
if (res.stage === 'end') {
|
50
|
-
current_requests -= 1;
|
51
|
-
debounced_render();
|
52
|
-
}
|
53
|
-
};
|
54
|
-
|
55
|
-
page.open(url, function(status) {
|
56
|
-
if (status !== 'success') {
|
57
|
-
console.log('Error with page ' + url);
|
58
|
-
phantom.exit();
|
59
|
-
}
|
60
|
-
});
|
61
|
-
|
62
|
-
|
63
|
-
function debounced_render() {
|
64
|
-
clearTimeout(last_request_timeout);
|
65
|
-
clearTimeout(final_timeout);
|
66
|
-
|
67
|
-
// If there's no more ongoing resource requests, wait for 1 second before
|
68
|
-
// rendering, just in case the page kicks off another request
|
69
|
-
if (current_requests < 1) {
|
70
|
-
clearTimeout(final_timeout);
|
71
|
-
last_request_timeout = setTimeout(function() {
|
72
|
-
console.log('Snapping ' + url + ' at width ' + view_port_width);
|
73
|
-
page.render(image_name);
|
74
|
-
phantom.exit();
|
75
|
-
}, 1000);
|
76
|
-
}
|
77
|
-
|
78
|
-
// Sometimes, straggling requests never make it back, in which
|
79
|
-
// case, timeout after 5 seconds and render the page anyway
|
80
|
-
final_timeout = setTimeout(function() {
|
81
|
-
console.log('Snapping ' + url + ' at width ' + view_port_width);
|
82
|
-
page.render(image_name);
|
83
|
-
phantom.exit();
|
84
|
-
}, 5000);
|
85
|
-
}
|