qat-web-video 9.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bf3c89384b93f390fcc340679384a1d7cf3a4a52eb10f813681906814eb18af7
4
+ data.tar.gz: ff05043001d9e372d8063c85d78a30f8edb1e9ebde30ae6e223ab16c3a378847
5
+ SHA512:
6
+ metadata.gz: '06494ab76abb855a8aed9d6535a0754174ad94779739f96da2a490ef687e65e0270f904a09132f7c63d3d7cb21c1b3ccc9c139d92ad9d5bb88f44210cac4ab2f'
7
+ data.tar.gz: 8e1e92a71affbb2d8bc54b3de5d1531ce88c8614bdfb29a0a45ebe3e5e375ee2e3c348c911882b889ec8e2d4824f61a94f8c45b00e34f3467d602dd8248110b3
@@ -0,0 +1,35 @@
1
+ # Monkey Patch Description:
2
+ #
3
+ # This monkey patch modifies the behavior of the `stop_and_save` within the `VideoRecorder`
4
+ # from the 'headless' gem. It is applied to address a specific issue or add custom
5
+ # functionality required for our project.
6
+ #
7
+ # Original method behavior:
8
+ # - File.exists? was removed in Ruby 3.2.0 (deprecated in 2.2)
9
+ # https://bugs.ruby-lang.org/issues/17391
10
+ # https://github.com/ruby/ruby/commit/bf97415c02b11a8949f715431aca9eeb6311add2
11
+ # Sadly the gem Headless is currently outdated thus this patch
12
+ #
13
+ # Changes Made:
14
+ # - Change `File.exists?` to `File.exist?`
15
+ #
16
+ # Note: This patch should be reviewed and updated as needed with future gem updates.
17
+ #
18
+ # Author: Bruno Penedo
19
+
20
+ require 'headless'
21
+
22
+ class Headless
23
+ class VideoRecorder
24
+ def stop_and_save(path)
25
+ CliUtil.kill_process(@pid_file_path, :wait => true)
26
+ if File.exist? @tmp_file_path
27
+ begin
28
+ FileUtils.mv(@tmp_file_path, path)
29
+ rescue Errno::EINVAL
30
+ nil
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1 @@
1
+ require_relative 'headless/video/video_recorder_ext'
@@ -0,0 +1,18 @@
1
+ module QAT::Web
2
+ module Browser
3
+ module Loader
4
+
5
+ private
6
+
7
+ def maximize_browser_window(driver, screen)
8
+ if screen.xvfb
9
+ driver.resize_window_to(driver.current_window_handle, screen.width, screen.height)
10
+
11
+ screen.start_video_capture if %w(always success failure).include? ENV['QAT_WEB_VIDEO_MODE']
12
+ else
13
+ driver.maximize_window(driver.current_window_handle) if driver.respond_to? :maximize_window
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,80 @@
1
+ require 'qat/web/screen/loader'
2
+ require 'headless/core_ext/random_display'
3
+ require 'qat/logger'
4
+ require 'headless_ext'
5
+
6
+ module QAT::Web
7
+ module Screen
8
+
9
+ #Screen wrapper to represent an abstract display. Can have a Headless instance associated.
10
+ class Wrapper
11
+ include QAT::Logger
12
+
13
+ # Video recording configurations exception
14
+ #@since 6.0.0
15
+ class VideoRecordingConfigError < StandardError
16
+ end
17
+
18
+ #Start a new Xvfb instance
19
+ #@return [Headless] Xvfb instance
20
+ #@since 6.0.0
21
+ def start
22
+ if %w(always success failure).include?(ENV['QAT_WEB_VIDEO_MODE']) and (@options[:video].nil? or @options[:video].empty?)
23
+ raise(VideoRecordingConfigError, "Video recording configuration is missing!")
24
+ end
25
+
26
+ @xvfb = Headless.new @options
27
+ @xvfb.start
28
+ log.info "Xvfb #{name} screen started"
29
+ @xvfb
30
+ end
31
+
32
+ #Start Xvfb web capture
33
+ #@since 6.0.0
34
+ def start_video_capture
35
+ @xvfb.video.start_capture
36
+ log.debug "Started video capture"
37
+ end
38
+
39
+ #Stop Xvfb web capture and discard the recorded web
40
+ #@since 6.0.0
41
+ def stop_and_discard_video_capture
42
+ return unless video_capture_running?
43
+ @xvfb.video.stop_and_discard
44
+ log.debug "Stopped and discarded video capture"
45
+ end
46
+
47
+ #Stop Xvfb web capture and save the recorded web
48
+ #@since 6.0.0
49
+ def stop_and_save_video_capture(path = nil)
50
+ return unless video_capture_running?
51
+ path ||= self.class.default_video_name
52
+ @xvfb.video.stop_and_save path
53
+ log.info "Saving video capture to #{path}"
54
+ path
55
+ end
56
+
57
+ #Check if Xvfb web capture is running
58
+ #@since 6.0.0
59
+ def video_capture_running?
60
+ return false unless @xvfb
61
+ return false if ENV['QAT_WEB_VIDEO_MODE'] == 'never'
62
+ @xvfb.video.capture_running?.tap { |value| log.debug "Video capture#{value ? '' : ' not'} running" }
63
+ rescue Headless::Exception => e
64
+ log.debug { "An error occurred while checking web recording:" }
65
+ log.debug { e }
66
+ log.debug { "Assuming video capture is not running" }
67
+ false
68
+ end
69
+
70
+ def self.default_video_name
71
+ return @@default_video_name ||= "video.mkv"
72
+ end
73
+
74
+ def self.default_video_name=(path)
75
+ @@default_video_name = path
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,5 @@
1
+ require 'qat/web/browser/firefox/loader/helper'
2
+ require_relative 'core_ext/browser/firefox/loader/helper'
3
+
4
+ require 'qat/web/screen/wrapper'
5
+ require_relative 'core_ext/screen/wrapper'
@@ -0,0 +1,2 @@
1
+ require 'qat/web/cucumber'
2
+ require_relative 'hooks/video'
@@ -0,0 +1,38 @@
1
+ require 'qat/web/hooks/common'
2
+ require 'qat/web/exceptions'
3
+ require_relative '../../video'
4
+
5
+ module QAT::Web
6
+ module Exceptions
7
+ VIDEO = GLOBAL.dup
8
+ end
9
+ end
10
+
11
+ Before do |scenario|
12
+ QAT::Web::Screen::Wrapper.default_video_name = File.join('public', "#{QAT::Web::Hooks::Common.scenario_tag(scenario)}.mkv")
13
+
14
+ if %w(always success failure).include?(ENV['QAT_WEB_VIDEO_MODE']) and QAT::Web::Screen::Factory.current_screen and not QAT::Web::Screen::Factory.current_screen.video_capture_running?
15
+ QAT::Web::Screen::Factory.current_screen.start_video_capture
16
+ end
17
+ end
18
+
19
+ After do |scenario|
20
+ if ENV['QAT_WEB_VIDEO_MODE'] and QAT::Web::Screen::Factory.current_screen and QAT::Web::Screen::Factory.current_screen.video_capture_running?
21
+ case ENV['QAT_WEB_VIDEO_MODE']
22
+ when 'always'
23
+ attach QAT::Web::Screen::Factory.current_screen.stop_and_save_video_capture, 'video/mp4'
24
+ when 'success'
25
+ if scenario.passed?
26
+ attach QAT::Web::Screen::Factory.current_screen.stop_and_save_video_capture, 'video/mp4'
27
+ else
28
+ QAT::Web::Screen::Factory.current_screen.stop_and_discard_video_capture
29
+ end
30
+ when 'failure'
31
+ if scenario.failed? and QAT::Web::Exceptions::VIDEO.any? { |exception| scenario.exception.kind_of?(exception) }
32
+ attach QAT::Web::Screen::Factory.current_screen.stop_and_save_video_capture, 'video/mp4'
33
+ else
34
+ QAT::Web::Screen::Factory.current_screen.stop_and_discard_video_capture
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ #QAT global namespace
2
+ module QAT
3
+ #Web Module namespace for browser interaction API
4
+ #@since 6.0.0
5
+ module Web
6
+ #Video Module namespace for browser recorder interaction API
7
+ #@since 6.0.0
8
+ module Video
9
+ # Represents QAT-Web-Video's version
10
+ VERSION = '9.0.0'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ require_relative 'core_ext'
2
+ require_relative 'video/version'
3
+ require_relative 'video/cucumber'
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qat-web-video
3
+ version: !ruby/object:Gem::Version
4
+ version: 9.0.0
5
+ platform: ruby
6
+ authors:
7
+ - QAT
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-01-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: headless
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.3.1
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.3.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.21.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.21.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: qat-devel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 9.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 9.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: qat-cucumber
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 9.0.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 9.0.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: selenium-webdriver
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 4.12.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 4.12.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: sinatra
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.1.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: syntax
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.2.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.2.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: webrick
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.8.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.8.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: qat-web
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 9.0.3
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 9.0.3
139
+ description: " QAT-Web-Video is a screen recorder for Web testing evidences, with
140
+ support for various browsers and webdrivers.\n"
141
+ email: qatoolkit@readinessit.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - lib/headless/video/video_recorder_ext.rb
147
+ - lib/headless_ext.rb
148
+ - lib/qat/web/core_ext.rb
149
+ - lib/qat/web/core_ext/browser/firefox/loader/helper.rb
150
+ - lib/qat/web/core_ext/screen/wrapper.rb
151
+ - lib/qat/web/video.rb
152
+ - lib/qat/web/video/cucumber.rb
153
+ - lib/qat/web/video/hooks/video.rb
154
+ - lib/qat/web/video/version.rb
155
+ homepage: https://gitlab.readinessit.com/qa-toolkit/qat-web-video
156
+ licenses:
157
+ - Nonstandard
158
+ metadata: {}
159
+ post_install_message:
160
+ rdoc_options: []
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: 3.2.2
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ requirements: []
174
+ rubygems_version: 3.3.26
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: QAT-Web-Video is a screen recorder for Web testing evidences
178
+ test_files: []