wraith 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +9 -6
- data/README.md +2 -1
- data/lib/wraith/gallery_template/slideshow_template.erb +31 -14
- data/lib/wraith/helpers/utilities.rb +2 -0
- data/lib/wraith/save_images.rb +54 -2
- data/lib/wraith/version.rb +1 -1
- data/spec/_helpers.rb +1 -0
- data/spec/before_capture_spec.rb +56 -13
- data/spec/configs/test_config--chrome.yaml +53 -0
- data/spec/js/global--chrome.js +4 -0
- data/spec/js/path--chrome.js +4 -0
- data/spec/save_images_spec.rb +18 -0
- data/templates/javascript/cookies_and_headers--phantom.js +1 -1
- data/templates/javascript/interact--chrome.js +4 -0
- data/templates/javascript/wait--chrome.js +2 -0
- data/wraith.gemspec +3 -0
- metadata +53 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ccdc604fedb66c5f447e8f68105daf4b4eba0fd
|
4
|
+
data.tar.gz: 850ccf4e7ab0afcdbe63a8cf6f9a4469f77b846e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 670097d8987a074e52237edfbec825e81beb9e02bebf2ea63eba624fbb2b6c33100e2f5f3a1c506f2a868cf7d6f967ed330ba8c11e7b3633016b3e70ed65fe0e
|
7
|
+
data.tar.gz: cd33ec5eea8efa8a444fa3759b7268d5c9af16d952b79573a2997858b36f842371cd17e258dd98a75251e62bf86d9e11357248890402b8a117c89a15bb37ac33
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.1
|
data/.travis.yml
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
+
sudo: false
|
2
|
+
addons:
|
3
|
+
apt:
|
4
|
+
packages:
|
5
|
+
- google-chrome-stable
|
6
|
+
|
1
7
|
language: ruby
|
2
8
|
rvm:
|
3
|
-
- 2.
|
4
|
-
|
5
|
-
-
|
6
|
-
- gem --version
|
7
|
-
script: bundle exec rspec
|
9
|
+
- 2.4.1
|
10
|
+
script:
|
11
|
+
- bundle exec rspec
|
8
12
|
notifications:
|
9
13
|
email:
|
10
14
|
recipients:
|
@@ -13,4 +17,3 @@ notifications:
|
|
13
17
|
on_success: never
|
14
18
|
slack:
|
15
19
|
secure: BgRAqwHabAtIBgtApDjyUiND2SNxd4sHMgq4ffnJ+EoMme6RSUAeK0G6LLyaGAk6YcpCeWRGOccEpzai87R3ckv6uycUVGxFcTvPmCEClakbUelWovVEyVT3hPLWznxJ8pz3EVB2+5aJnAsTg5M2ZnYtk3a5C1mrPS+WKceE/Ls=
|
16
|
-
sudo: false
|
data/README.md
CHANGED
@@ -40,13 +40,14 @@ Whichever mode you decide to run Wraith in, the process it follows is generally
|
|
40
40
|
|
41
41
|
## Requirements
|
42
42
|
|
43
|
-
[ImageMagick](http://www.imagemagick.org/) is required to compare the screenshots.
|
43
|
+
[ImageMagick](http://www.imagemagick.org/) is required to compare the screenshots and crop images.
|
44
44
|
|
45
45
|
Wraith also requires at least one of these headless browsers:
|
46
46
|
|
47
47
|
* [PhantomJS](http://phantomjs.org)
|
48
48
|
* [CasperJS](http://casperjs.org/) (which can be used to target specific selectors)
|
49
49
|
* [SlimerJS](http://slimerjs.org)
|
50
|
+
* [Chrome](https://askubuntu.com/questions/510056/how-to-install-google-chrome/510063) (Currently using Selenium WebDriver + Chromedriver for Chrome; Can target specific selectors)
|
50
51
|
|
51
52
|
## Contributing
|
52
53
|
|
@@ -108,28 +108,41 @@
|
|
108
108
|
</style>
|
109
109
|
<script type="text/javascript">
|
110
110
|
$(function() {
|
111
|
-
$('.slideshow')
|
111
|
+
var slideshow = $('.slideshow');
|
112
|
+
var compareModal = $('.compare-modal');
|
113
|
+
|
114
|
+
slideshow.cycle({
|
112
115
|
fx: 'scrollHorz',
|
113
116
|
speed: 300,
|
114
117
|
prev: '.prev',
|
115
118
|
next: '.next',
|
116
119
|
before: function (curr, next, opts) {
|
117
120
|
$('.current').removeClass('current');
|
118
|
-
var
|
121
|
+
var $next = $(next);
|
122
|
+
var path = $next.find('.path').attr('name');
|
119
123
|
$.each($('.list-group .list-group-item a'), function() {
|
120
124
|
if ($(this).attr('href').substring(1) == path) {
|
121
125
|
$(this).parent().addClass('checked');
|
122
126
|
$(this).parent().addClass('current');
|
123
127
|
}
|
124
|
-
})
|
128
|
+
});
|
129
|
+
|
130
|
+
var newImage = $next.find('a.shot:eq(0)').attr('href');
|
131
|
+
var oldImage = $next.find('a.shot:eq(1)').attr('href');
|
132
|
+
var diffImage = $next.find('a.shot:eq(2)').attr('href');
|
133
|
+
compareModal.html('<div class="compare-container"><img src="'+newImage+'"/><img src="'+oldImage+'"/><img src="'+diffImage+'"/></div>');
|
125
134
|
},
|
126
135
|
timeout: 0
|
127
136
|
});
|
128
137
|
|
138
|
+
$(document).on('click', '.compare', function() {
|
139
|
+
compareModal.show();
|
140
|
+
});
|
141
|
+
|
129
142
|
$('.list-group .list-group-item a').unbind().on('click', function(){
|
130
143
|
var href = $(this).attr('href').substring(1);
|
131
144
|
|
132
|
-
|
145
|
+
slideshow.cycle($('.slide.'+href+':first').index());
|
133
146
|
})
|
134
147
|
|
135
148
|
$('.shot').unbind().on('click', function(e){
|
@@ -138,20 +151,24 @@
|
|
138
151
|
window.open(url,'_blank');
|
139
152
|
})
|
140
153
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
154
|
+
compareModal.on('click', function(){
|
155
|
+
$(this).hide();
|
156
|
+
});
|
157
|
+
|
158
|
+
$(document).on('keyup', function(e) {
|
159
|
+
if (e.keyCode === 27) { // Escape
|
160
|
+
compareModal.hide();
|
161
|
+
} else if (e.keyCode === 37) { // Left
|
162
|
+
slideshow.cycle('prev');
|
163
|
+
} else if (e.keyCode === 39) { // Right
|
164
|
+
slideshow.cycle('next');
|
165
|
+
}
|
166
|
+
});
|
151
167
|
})
|
152
168
|
</script>
|
153
169
|
</head>
|
154
170
|
<body>
|
171
|
+
<div class="compare-modal" style="display: none;"></div>
|
155
172
|
<div class="container">
|
156
173
|
<div class="row">
|
157
174
|
<div class="col-sm-12 col-md-3">
|
@@ -33,6 +33,7 @@ def list_debug_information
|
|
33
33
|
command_run = ARGV.join ' '
|
34
34
|
ruby_version = run_command_safely("ruby -v") || "Ruby not installed"
|
35
35
|
phantomjs_version = run_command_safely("phantomjs --version") || "PhantomJS not installed"
|
36
|
+
chromedriver_version = run_command_safely("chromedriver --version") || "chromedriver not installed"
|
36
37
|
casperjs_version = run_command_safely("casperjs --version") || "CasperJS not installed"
|
37
38
|
imagemagick_version = run_command_safely("convert -version") || "ImageMagick not installed"
|
38
39
|
|
@@ -42,6 +43,7 @@ def list_debug_information
|
|
42
43
|
logger.debug " Ruby version: #{ruby_version}"
|
43
44
|
logger.debug " ImageMagick: #{imagemagick_version}"
|
44
45
|
logger.debug " PhantomJS version: #{phantomjs_version}"
|
46
|
+
logger.debug " chromedriver version: #{chromedriver_version}"
|
45
47
|
logger.debug " CasperJS version: #{casperjs_version}"
|
46
48
|
# @TODO - add a SlimerJS equivalent
|
47
49
|
logger.debug "#################################################"
|
data/lib/wraith/save_images.rb
CHANGED
@@ -5,6 +5,8 @@ require "wraith/helpers/capture_options"
|
|
5
5
|
require "wraith/helpers/logger"
|
6
6
|
require "wraith/helpers/save_metadata"
|
7
7
|
require "wraith/helpers/utilities"
|
8
|
+
require "selenium-webdriver"
|
9
|
+
require 'mini_magick'
|
8
10
|
|
9
11
|
class Wraith::SaveImages
|
10
12
|
include Logging
|
@@ -75,8 +77,12 @@ class Wraith::SaveImages
|
|
75
77
|
def parallel_task(jobs)
|
76
78
|
Parallel.each(jobs, :in_threads => 8) do |_label, _path, width, url, filename, selector, global_before_capture, path_before_capture|
|
77
79
|
begin
|
78
|
-
|
79
|
-
|
80
|
+
if meta.engine == "chrome"
|
81
|
+
capture_image_selenium(width, url, filename, selector, global_before_capture, path_before_capture)
|
82
|
+
else
|
83
|
+
command = construct_command(width, url, filename, selector, global_before_capture, path_before_capture)
|
84
|
+
attempt_image_capture(command, filename)
|
85
|
+
end
|
80
86
|
rescue => e
|
81
87
|
logger.error e
|
82
88
|
create_invalid_image(filename, width)
|
@@ -84,6 +90,52 @@ class Wraith::SaveImages
|
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
93
|
+
# currently only chrome headless at 1x scaling
|
94
|
+
def get_driver
|
95
|
+
case meta.engine
|
96
|
+
when "chrome"
|
97
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
98
|
+
options.add_argument('--disable-gpu')
|
99
|
+
options.add_argument('--headless')
|
100
|
+
options.add_argument('--device-scale-factor=1') # have to change cropping for 2x. also this is faster
|
101
|
+
options.add_argument('--force-device-scale-factor')
|
102
|
+
options.add_argument("--window-size=1200,1500") # resize later so we can reuse drivers
|
103
|
+
options.add_argument("--hide-scrollbars") # hide scrollbars from screenshots
|
104
|
+
Selenium::WebDriver.for :chrome, options: options
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# resize to fit entire page
|
109
|
+
def resize_to_fit_page driver
|
110
|
+
width = driver.execute_script("return Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);")
|
111
|
+
height = driver.execute_script("return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);")
|
112
|
+
driver.manage.window.resize_to(width, height)
|
113
|
+
end
|
114
|
+
|
115
|
+
# crop an image around the coordinates of an element
|
116
|
+
def crop_selector driver, selector, image_location
|
117
|
+
el = driver.find_element(:css, selector)
|
118
|
+
image = MiniMagick::Image.open(image_location)
|
119
|
+
image.crop "#{el.rect.width}x#{el.rect.height}+#{el.rect.x}+#{el.rect.y}"
|
120
|
+
image.write(image_location)
|
121
|
+
end
|
122
|
+
|
123
|
+
def capture_image_selenium(screen_sizes, url, file_name, selector, global_before_capture, path_before_capture)
|
124
|
+
driver = get_driver
|
125
|
+
screen_sizes.to_s.split(",").each do |screen_size|
|
126
|
+
width, height = screen_size.split("x")
|
127
|
+
new_file_name = file_name.sub('MULTI', screen_size)
|
128
|
+
driver.manage.window.resize_to(width, height || 1500)
|
129
|
+
driver.navigate.to url
|
130
|
+
driver.execute_async_script(File.read(global_before_capture)) if global_before_capture
|
131
|
+
driver.execute_async_script(File.read(path_before_capture)) if path_before_capture
|
132
|
+
resize_to_fit_page(driver) unless height
|
133
|
+
driver.save_screenshot(new_file_name)
|
134
|
+
crop_selector(driver, selector, new_file_name) if selector && selector.length > 0
|
135
|
+
end
|
136
|
+
driver.quit
|
137
|
+
end
|
138
|
+
|
87
139
|
def construct_command(width, url, file_name, selector, global_before_capture, path_before_capture)
|
88
140
|
width = prepare_widths_for_cli(width)
|
89
141
|
selector = selector.gsub '#', '\#' # make sure id selectors aren't escaped in the CLI
|
data/lib/wraith/version.rb
CHANGED
data/spec/_helpers.rb
CHANGED
data/spec/before_capture_spec.rb
CHANGED
@@ -10,16 +10,30 @@ def run_js_then_capture(config)
|
|
10
10
|
expect(diff).to eq "0.0"
|
11
11
|
end
|
12
12
|
|
13
|
+
def run_js_then_capture_chrome(config)
|
14
|
+
saving = Wraith::SaveImages.new(config_chrome)
|
15
|
+
generated_image = "shots_chrome/test/temporary_jsified_image.png"
|
16
|
+
saving.capture_image_selenium('320', 'http://www.bbc.com/afrique', generated_image, selector, config[:global_js], config[:path_js])
|
17
|
+
Wraith::CompareImages.new(config_chrome).compare_task(generated_image, config[:output_should_look_like], "shots/test/test_diff.png", "shots/test/test.txt")
|
18
|
+
diff = File.open("shots/test/test.txt", "rb").read
|
19
|
+
expect(diff).to eq "0.0"
|
20
|
+
end
|
21
|
+
|
13
22
|
describe Wraith do
|
14
23
|
let(:config_name) { get_path_relative_to __FILE__, "./configs/test_config--casper.yaml" }
|
24
|
+
let(:config_chrome) { get_path_relative_to __FILE__, "./configs/test_config--chrome.yaml" }
|
15
25
|
let(:wraith) { Wraith::Wraith.new(config_name) }
|
16
26
|
let(:selector) { "body" }
|
17
27
|
let(:before_suite_js) { "spec/js/global.js" }
|
18
28
|
let(:before_capture_js) { "spec/js/path.js" }
|
29
|
+
let(:before_suite_js_chrome) { "spec/js/global--chrome.js" }
|
30
|
+
let(:before_capture_js_chrome) { "spec/js/path--chrome.js" }
|
19
31
|
|
20
32
|
before(:each) do
|
21
33
|
Wraith::FolderManager.new(config_name).clear_shots_folder
|
34
|
+
Wraith::FolderManager.new(config_chrome).clear_shots_folder
|
22
35
|
Dir.mkdir("shots/test")
|
36
|
+
Dir.mkdir("shots_chrome/test")
|
23
37
|
end
|
24
38
|
|
25
39
|
describe "different ways of determining the before_capture file" do
|
@@ -43,37 +57,66 @@ describe Wraith do
|
|
43
57
|
end
|
44
58
|
end
|
45
59
|
|
46
|
-
|
47
|
-
|
48
|
-
describe "When hooking into before_capture (CasperJS)" do
|
60
|
+
describe "When hooking into before_capture (Chrome)" do
|
49
61
|
it "Executes the global JS before capturing" do
|
50
|
-
|
51
|
-
:global_js =>
|
62
|
+
run_js_then_capture_chrome(
|
63
|
+
:global_js => before_suite_js_chrome,
|
52
64
|
:path_js => false,
|
53
65
|
:output_should_look_like => "spec/base/global.png",
|
54
|
-
:engine => "
|
66
|
+
:engine => "chrome"
|
55
67
|
)
|
56
68
|
end
|
57
69
|
|
58
70
|
it "Executes the path-level JS before capturing" do
|
59
|
-
|
71
|
+
run_js_then_capture_chrome(
|
60
72
|
:global_js => false,
|
61
|
-
:path_js =>
|
73
|
+
:path_js => before_capture_js_chrome,
|
62
74
|
:output_should_look_like => "spec/base/path.png",
|
63
|
-
:engine => "
|
75
|
+
:engine => "chrome"
|
64
76
|
)
|
65
77
|
end
|
66
78
|
|
67
79
|
it "Executes the global JS before the path-level JS" do
|
68
|
-
|
69
|
-
:global_js =>
|
70
|
-
:path_js =>
|
80
|
+
run_js_then_capture_chrome(
|
81
|
+
:global_js => before_suite_js_chrome,
|
82
|
+
:path_js => before_capture_js_chrome,
|
71
83
|
:output_should_look_like => "spec/base/path.png",
|
72
|
-
:engine => "
|
84
|
+
:engine => "chrome"
|
73
85
|
)
|
74
86
|
end
|
75
87
|
end
|
76
88
|
|
89
|
+
# @TODO - we need tests determining the path to "path-level before_capture hooks"
|
90
|
+
# @TODO - uncomment and figure out why broken OR deprecate
|
91
|
+
# describe "When hooking into before_capture (CasperJS)" do
|
92
|
+
# it "Executes the global JS before capturing" do
|
93
|
+
# run_js_then_capture(
|
94
|
+
# :global_js => before_suite_js,
|
95
|
+
# :path_js => false,
|
96
|
+
# :output_should_look_like => "spec/base/global.png",
|
97
|
+
# :engine => "casperjs"
|
98
|
+
# )
|
99
|
+
# end
|
100
|
+
|
101
|
+
# it "Executes the path-level JS before capturing" do
|
102
|
+
# run_js_then_capture(
|
103
|
+
# :global_js => false,
|
104
|
+
# :path_js => before_capture_js,
|
105
|
+
# :output_should_look_like => "spec/base/path.png",
|
106
|
+
# :engine => "casperjs"
|
107
|
+
# )
|
108
|
+
# end
|
109
|
+
|
110
|
+
# it "Executes the global JS before the path-level JS" do
|
111
|
+
# run_js_then_capture(
|
112
|
+
# :global_js => before_suite_js,
|
113
|
+
# :path_js => before_capture_js,
|
114
|
+
# :output_should_look_like => "spec/base/path.png",
|
115
|
+
# :engine => "casperjs"
|
116
|
+
# )
|
117
|
+
# end
|
118
|
+
# end
|
119
|
+
|
77
120
|
# @TODO - uncomment and figure out why broken
|
78
121
|
# describe "When hooking into before_capture (PhantomJS)" do
|
79
122
|
# let(:config_name) { get_path_relative_to __FILE__, "./configs/test_config--phantom.yaml" }
|
@@ -0,0 +1,53 @@
|
|
1
|
+
##########
|
2
|
+
### NB: the paths in this YAML config are relative to the root of the Wraith directory,
|
3
|
+
### as `bundle exec rspec` is run from the root.
|
4
|
+
##########
|
5
|
+
|
6
|
+
#Headless browser option
|
7
|
+
browser:
|
8
|
+
phantomjs: "chrome"
|
9
|
+
|
10
|
+
# Type the name of the directory that shots will be stored in
|
11
|
+
directory: 'shots_chrome'
|
12
|
+
|
13
|
+
# Add only 2 domains, key will act as a label
|
14
|
+
domains:
|
15
|
+
afrique: "http://www.bbc.com/afrique"
|
16
|
+
russian: "http://www.bbc.com/russian"
|
17
|
+
|
18
|
+
#Type screen widths below, here are a couple of examples
|
19
|
+
screen_widths:
|
20
|
+
- 600
|
21
|
+
- 1280
|
22
|
+
|
23
|
+
#Type page URL paths below, here are a couple of examples
|
24
|
+
paths:
|
25
|
+
home: /
|
26
|
+
home_menu:
|
27
|
+
path: /
|
28
|
+
selector: "#orb-nav-more"
|
29
|
+
uk_index: /uk
|
30
|
+
|
31
|
+
# (optional) JavaScript file to execute before taking screenshot of every path. Default: nil
|
32
|
+
# before_capture: 'javascript/interact--chrome.js'
|
33
|
+
# before_capture: 'javascript/wait--chrome.js'
|
34
|
+
|
35
|
+
#Amount of fuzz ImageMagick will use
|
36
|
+
fuzz: '20%'
|
37
|
+
|
38
|
+
# (optional) The maximum acceptable level of difference (in %) between two images before Wraith reports a failure. Default: 0
|
39
|
+
threshold: 5
|
40
|
+
|
41
|
+
# (optional) Specify the template (and generated thumbnail sizes) for the gallery output.
|
42
|
+
gallery:
|
43
|
+
template: 'slideshow_template' # Examples: 'basic_template' (default), 'slideshow_template'
|
44
|
+
thumb_width: 200
|
45
|
+
thumb_height: 200
|
46
|
+
|
47
|
+
# (optional) Choose which results are displayed in the gallery, and in what order. Default: alphanumeric
|
48
|
+
# Options:
|
49
|
+
# alphanumeric - all paths (with or without a difference) are shown, sorted by path
|
50
|
+
# diffs_first - all paths (with or without a difference) are shown, sorted by difference size (largest first)
|
51
|
+
# diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
|
52
|
+
# Note: different screen widths are always grouped together.
|
53
|
+
mode: diffs_first
|
data/spec/save_images_spec.rb
CHANGED
@@ -3,19 +3,25 @@ require "image_size"
|
|
3
3
|
|
4
4
|
describe Wraith do
|
5
5
|
let(:config_name) { get_path_relative_to __FILE__, "./configs/test_config--phantom.yaml" }
|
6
|
+
let(:config_chrome) { get_path_relative_to __FILE__, "./configs/test_config--chrome.yaml" }
|
6
7
|
let(:test_url1) { "http://www.bbc.com/afrique" }
|
7
8
|
let(:test_url2) { "http://www.bbc.com/russian" }
|
8
9
|
let(:test_image1) { "shots/test/test1.png" }
|
10
|
+
let(:test_image_chrome) { "shots_chrome/test/test_chrome.png" }
|
11
|
+
let(:test_image_chrome_selector) { "shots_chrome/test/test_chrome_selector.png" }
|
9
12
|
let(:test_image2) { "shots/test/test(2).png" }
|
10
13
|
let(:diff_image) { "shots/test/test_diff.png" }
|
11
14
|
let(:data_txt) { "shots/test/test.txt" }
|
12
15
|
let(:selector) { "" }
|
13
16
|
let(:saving) { Wraith::SaveImages.new(config_name) }
|
17
|
+
let(:saving_chrome) { Wraith::SaveImages.new(config_chrome) }
|
14
18
|
let(:wraith) { Wraith::Wraith.new(config_name) }
|
15
19
|
|
16
20
|
before(:each) do
|
17
21
|
Wraith::FolderManager.new(config_name).clear_shots_folder
|
22
|
+
Wraith::FolderManager.new(config_chrome).clear_shots_folder
|
18
23
|
Dir.mkdir("shots/test")
|
24
|
+
Dir.mkdir("shots_chrome/test")
|
19
25
|
end
|
20
26
|
|
21
27
|
describe "When capturing an image" do
|
@@ -26,6 +32,18 @@ describe Wraith do
|
|
26
32
|
`#{capture_image}`
|
27
33
|
expect(image_size[0]).to eq 320
|
28
34
|
end
|
35
|
+
it "saves image chrome" do
|
36
|
+
capture_image = saving_chrome.capture_image_selenium("1080x600", test_url1, test_image_chrome, selector, false, false)
|
37
|
+
image_size_chrome = ImageSize.path(test_image_chrome).size
|
38
|
+
expect(image_size_chrome[0]).to eq 1080
|
39
|
+
end
|
40
|
+
it "crops around a selector" do
|
41
|
+
selector = "#orb-nav-more"
|
42
|
+
capture_image = saving_chrome.capture_image_selenium(1440, test_url1, test_image_chrome_selector, selector, false, false)
|
43
|
+
image_size_chrome_selector = ImageSize.path(test_image_chrome_selector).size
|
44
|
+
expect(image_size_chrome_selector[0]).to eq 673
|
45
|
+
expect(image_size_chrome_selector[1]).to eq 40
|
46
|
+
end
|
29
47
|
end
|
30
48
|
|
31
49
|
describe "When comparing images" do
|
data/wraith.gemspec
CHANGED
@@ -24,9 +24,12 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_runtime_dependency 'rake'
|
26
26
|
spec.add_runtime_dependency 'image_size'
|
27
|
+
spec.add_runtime_dependency 'mini_magick', "~> 4.8"
|
27
28
|
spec.add_runtime_dependency 'anemone'
|
28
29
|
spec.add_runtime_dependency 'robotex'
|
29
30
|
spec.add_runtime_dependency 'log4r'
|
30
31
|
spec.add_runtime_dependency 'thor'
|
31
32
|
spec.add_runtime_dependency 'parallel'
|
33
|
+
spec.add_runtime_dependency 'selenium-webdriver', "~> 3.5"
|
34
|
+
spec.add_runtime_dependency 'chromedriver-helper', "~> 1.1"
|
32
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wraith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Blooman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pry
|
@@ -82,6 +82,20 @@ dependencies:
|
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: mini_magick
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '4.8'
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '4.8'
|
85
99
|
- !ruby/object:Gem::Dependency
|
86
100
|
name: anemone
|
87
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,6 +166,34 @@ dependencies:
|
|
152
166
|
- - ">="
|
153
167
|
- !ruby/object:Gem::Version
|
154
168
|
version: '0'
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: selenium-webdriver
|
171
|
+
requirement: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - "~>"
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '3.5'
|
176
|
+
type: :runtime
|
177
|
+
prerelease: false
|
178
|
+
version_requirements: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - "~>"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '3.5'
|
183
|
+
- !ruby/object:Gem::Dependency
|
184
|
+
name: chromedriver-helper
|
185
|
+
requirement: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - "~>"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '1.1'
|
190
|
+
type: :runtime
|
191
|
+
prerelease: false
|
192
|
+
version_requirements: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - "~>"
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '1.1'
|
155
197
|
description: Wraith is a screenshot comparison tool, created by developers at BBC
|
156
198
|
News.
|
157
199
|
email:
|
@@ -206,6 +248,7 @@ files:
|
|
206
248
|
- spec/before_capture_spec.rb
|
207
249
|
- spec/config_spec.rb
|
208
250
|
- spec/configs/test_config--casper.yaml
|
251
|
+
- spec/configs/test_config--chrome.yaml
|
209
252
|
- spec/configs/test_config--imports.yaml
|
210
253
|
- spec/configs/test_config--phantom.yaml
|
211
254
|
- spec/configs/test_config--spider.yaml
|
@@ -213,7 +256,9 @@ files:
|
|
213
256
|
- spec/gallery_spec.rb
|
214
257
|
- spec/helper_spec.rb
|
215
258
|
- spec/js/custom_snap_file.js
|
259
|
+
- spec/js/global--chrome.js
|
216
260
|
- spec/js/global.js
|
261
|
+
- spec/js/path--chrome.js
|
217
262
|
- spec/js/path.js
|
218
263
|
- spec/resize_reload_spec.rb
|
219
264
|
- spec/save_images_spec.rb
|
@@ -230,8 +275,10 @@ files:
|
|
230
275
|
- templates/javascript/disable_javascript--casper.js
|
231
276
|
- templates/javascript/disable_javascript--phantom.js
|
232
277
|
- templates/javascript/interact--casper.js
|
278
|
+
- templates/javascript/interact--chrome.js
|
233
279
|
- templates/javascript/interact--phantom.js
|
234
280
|
- templates/javascript/wait--casper.js
|
281
|
+
- templates/javascript/wait--chrome.js
|
235
282
|
- templates/javascript/wait--phantom.js
|
236
283
|
- wraith.gemspec
|
237
284
|
homepage: https://github.com/BBC-News/wraith
|
@@ -254,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
301
|
version: '0'
|
255
302
|
requirements: []
|
256
303
|
rubyforge_project:
|
257
|
-
rubygems_version: 2.
|
304
|
+
rubygems_version: 2.5.2
|
258
305
|
signing_key:
|
259
306
|
specification_version: 4
|
260
307
|
summary: Wraith is a screenshot comparison tool, created by developers at BBC News.
|
@@ -265,6 +312,7 @@ test_files:
|
|
265
312
|
- spec/before_capture_spec.rb
|
266
313
|
- spec/config_spec.rb
|
267
314
|
- spec/configs/test_config--casper.yaml
|
315
|
+
- spec/configs/test_config--chrome.yaml
|
268
316
|
- spec/configs/test_config--imports.yaml
|
269
317
|
- spec/configs/test_config--phantom.yaml
|
270
318
|
- spec/configs/test_config--spider.yaml
|
@@ -272,7 +320,9 @@ test_files:
|
|
272
320
|
- spec/gallery_spec.rb
|
273
321
|
- spec/helper_spec.rb
|
274
322
|
- spec/js/custom_snap_file.js
|
323
|
+
- spec/js/global--chrome.js
|
275
324
|
- spec/js/global.js
|
325
|
+
- spec/js/path--chrome.js
|
276
326
|
- spec/js/path.js
|
277
327
|
- spec/resize_reload_spec.rb
|
278
328
|
- spec/save_images_spec.rb
|