capybara-screenshot 1.0.25 → 1.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/capybara-screenshot/capybara.rb +12 -0
- data/lib/capybara-screenshot/cucumber.rb +6 -5
- data/lib/capybara-screenshot/rspec/html_link_reporter.rb +1 -1
- data/lib/capybara-screenshot/saver.rb +25 -13
- data/lib/capybara-screenshot/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b73d3b8338a3c2f426d7835f4396565c0bfe28b939f610337c331099f93f52b5
|
4
|
+
data.tar.gz: c5ec9f343c703e5ac2700b84dcde63a094c3609787ea7b1cfbbd1f470a5b0ce4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cd11454a82290ef985a5341e0dad1eaea6296ca5b6ea1f17522a5f8f43b6c68dd71cfd17426c8204fd352488b6ea876d2e8493b2ec0ce2e575590e13302b456
|
7
|
+
data.tar.gz: d17d96491ebc960f4fa47eec58b9dd60610c4a7839e878d8d40c3003cb054e891fc38e958ba42dbcf7ded095385fbb725cdd9e33e368fec51cd89358653c3576
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
21 Dec 2021 - 1.0.25 -> 1.0.26
|
2
|
+
|
3
|
+
* [Take screenshots of current window (when using multiple windows)](https://github.com/mattheworiordan/capybara-screenshot/pull/287)
|
4
|
+
* [Fix embedding screenshots into cucumber HTML reports](https://github.com/mattheworiordan/capybara-screenshot/pull/288)
|
5
|
+
|
1
6
|
4 Oct 2020 - 1.0.24 -> 1.0.25
|
2
7
|
|
3
8
|
* [Fix Cucumber 5 deprecation warnings](https://github.com/mattheworiordan/capybara-screenshot/pull/274)
|
@@ -27,4 +27,16 @@ module Capybara
|
|
27
27
|
Capybara::Screenshot.screenshot_and_open_image
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
module SessionScreenshotOverrides
|
32
|
+
def within_window(window_or_handle)
|
33
|
+
super
|
34
|
+
rescue Exception
|
35
|
+
Thread.current[:capybara_screenshot_offending_window] = window_or_handle
|
36
|
+
|
37
|
+
raise
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Session.prepend SessionScreenshotOverrides
|
30
42
|
end
|
@@ -15,17 +15,18 @@ After do |scenario|
|
|
15
15
|
|
16
16
|
# Trying to embed the screenshot into our output."
|
17
17
|
if File.exist?(saver.screenshot_path)
|
18
|
-
require "base64"
|
19
|
-
#encode the image into it's base64 representation
|
20
18
|
image = open(saver.screenshot_path, 'rb') {|io|io.read}
|
21
19
|
saver.display_image
|
22
|
-
#this will embed the image in the HTML report, embed() is defined in cucumber
|
23
|
-
encoded_img = Base64.encode64(image)
|
24
20
|
|
25
21
|
# cucumber5 deprecates embed in favor of attach
|
26
22
|
if respond_to? :attach
|
27
|
-
attach(
|
23
|
+
#this will embed the image in the HTML report, attach() is defined in cucumber
|
24
|
+
attach(image, 'image/png')
|
28
25
|
else
|
26
|
+
#encode the image into it's base64 representation
|
27
|
+
require "base64"
|
28
|
+
encoded_img = Base64.encode64(image)
|
29
|
+
#this will embed the image in the HTML report, embed() is defined in cucumber
|
29
30
|
embed(encoded_img, 'image/png;base64', "Screenshot of the error")
|
30
31
|
end
|
31
32
|
end
|
@@ -22,7 +22,7 @@ module Capybara
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def link_to_screenshot(title, path)
|
25
|
-
url = URI.escape("file://#{path}")
|
25
|
+
url = URI::DEFAULT_PARSER.escape("file://#{path}")
|
26
26
|
title = CGI.escape_html(title)
|
27
27
|
attributes = attributes_for_screenshot_link(url).map { |name, val| %{#{name}="#{CGI.escape_html(val)}"} }.join(" ")
|
28
28
|
"<a #{attributes}>#{title}</a>"
|
@@ -27,19 +27,21 @@ module Capybara
|
|
27
27
|
|
28
28
|
def save
|
29
29
|
current_path do |path|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
30
|
+
within_offending_window do
|
31
|
+
if path.empty?
|
32
|
+
warn 'WARN: Screenshot could not be saved. `page.current_path` is empty.'
|
33
|
+
else
|
34
|
+
begin
|
35
|
+
save_html if @html_save
|
36
|
+
rescue StandardError => e
|
37
|
+
warn "WARN: HTML source could not be saved. An exception is raised: #{e.inspect}."
|
38
|
+
end
|
39
|
+
|
40
|
+
begin
|
41
|
+
save_screenshot
|
42
|
+
rescue StandardError => e
|
43
|
+
warn "WARN: Screenshot could not be saved. An exception is raised: #{e.inspect}."
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
@@ -142,6 +144,16 @@ module Capybara
|
|
142
144
|
|
143
145
|
nil
|
144
146
|
end
|
147
|
+
|
148
|
+
def within_offending_window
|
149
|
+
return yield unless Thread.current[:capybara_screenshot_offending_window]
|
150
|
+
|
151
|
+
page.within_window(Thread.current[:capybara_screenshot_offending_window]) do
|
152
|
+
yield
|
153
|
+
end
|
154
|
+
|
155
|
+
Thread.current[:capybara_screenshot_offending_window] = nil
|
156
|
+
end
|
145
157
|
end
|
146
158
|
end
|
147
159
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-screenshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew O'Riordan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -243,9 +243,9 @@ licenses:
|
|
243
243
|
metadata:
|
244
244
|
bug_tracker_uri: https://github.com/mattheworiordan/capybara-screenshot/issues
|
245
245
|
changelog_uri: https://github.com/mattheworiordan/capybara-screenshot/blob/master/CHANGELOG.md
|
246
|
-
documentation_uri: https://www.rubydoc.info/gems/capybara-screenshot/1.0.
|
247
|
-
source_code_uri: https://github.com/mattheworiordan/capybara-screenshot/tree/v1.0.
|
248
|
-
post_install_message:
|
246
|
+
documentation_uri: https://www.rubydoc.info/gems/capybara-screenshot/1.0.26
|
247
|
+
source_code_uri: https://github.com/mattheworiordan/capybara-screenshot/tree/v1.0.26
|
248
|
+
post_install_message:
|
249
249
|
rdoc_options: []
|
250
250
|
require_paths:
|
251
251
|
- lib
|
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
261
|
version: '0'
|
262
262
|
requirements: []
|
263
263
|
rubygems_version: 3.0.3
|
264
|
-
signing_key:
|
264
|
+
signing_key:
|
265
265
|
specification_version: 4
|
266
266
|
summary: Automatically create snapshots when Cucumber steps fail with Capybara and
|
267
267
|
Rails
|