eyes_core 5.0.0 → 6.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 +4 -4
- data/CHANGELOG.md +504 -0
- data/Rakefile +35 -0
- data/eyes_core.gemspec +60 -0
- data/lib/applitools/core/batch_info.rb +2 -0
- data/lib/applitools/core/eyes_base.rb +106 -18
- data/lib/applitools/core/eyes_base_configuration.rb +9 -3
- data/lib/applitools/core/eyes_runner.rb +3 -2
- data/lib/applitools/core/test_results.rb +6 -1
- data/lib/applitools/core/universal_eyes_checks.rb +2 -1
- data/lib/applitools/core/universal_eyes_open.rb +2 -1
- data/lib/applitools/eyes_core/version.rb +10 -0
- data/lib/applitools/universal_sdk/universal_client.rb +26 -10
- data/lib/applitools/universal_sdk/universal_eyes_config.rb +10 -9
- data/lib/eyes_core.rb +1 -3
- metadata +14 -58
- data/ext/eyes_core/extconf.rb +0 -5
- data/ext/eyes_core/eyes_core.c +0 -252
- data/ext/eyes_core/eyes_core.h +0 -28
- data/lib/applitools/appium/android_region_provider.rb +0 -32
- data/lib/applitools/appium/android_screenshot.rb +0 -21
- data/lib/applitools/appium/driver.rb +0 -12
- data/lib/applitools/appium/eyes.rb +0 -189
- data/lib/applitools/appium/ios_region_provider.rb +0 -25
- data/lib/applitools/appium/ios_screenshot.rb +0 -10
- data/lib/applitools/appium/region_provider.rb +0 -51
- data/lib/applitools/appium/screenshot.rb +0 -30
- data/lib/applitools/appium/target.rb +0 -240
- data/lib/applitools/appium/utils.rb +0 -64
- data/lib/applitools/calabash/calabash_element.rb +0 -64
- data/lib/applitools/calabash/calabash_screenshot_provider.rb +0 -83
- data/lib/applitools/calabash/environment_detector.rb +0 -25
- data/lib/applitools/calabash/eyes.rb +0 -194
- data/lib/applitools/calabash/eyes_calabash_android_screenshot.rb +0 -68
- data/lib/applitools/calabash/eyes_calabash_ios_screenshot.rb +0 -30
- data/lib/applitools/calabash/eyes_calabash_screenshot.rb +0 -80
- data/lib/applitools/calabash/eyes_hooks.rb +0 -51
- data/lib/applitools/calabash/eyes_settings.rb +0 -45
- data/lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb +0 -95
- data/lib/applitools/calabash/full_page_capture_algorithm/base.rb +0 -51
- data/lib/applitools/calabash/full_page_capture_algorithm/ios_ui_table_view.rb +0 -150
- data/lib/applitools/calabash/full_page_capture_algorithm.rb +0 -26
- data/lib/applitools/calabash/os_versions.rb +0 -25
- data/lib/applitools/calabash/rspec_matchers.rb +0 -25
- data/lib/applitools/calabash/steps/android_eyes_session.rb +0 -37
- data/lib/applitools/calabash/steps/android_matchers.rb +0 -36
- data/lib/applitools/calabash/steps/eyes_session.rb +0 -42
- data/lib/applitools/calabash/steps/eyes_settings.rb +0 -59
- data/lib/applitools/calabash/steps/ios_eyes_session.rb +0 -15
- data/lib/applitools/calabash/steps/ios_matchers.rb +0 -17
- data/lib/applitools/calabash/steps/matchers.rb +0 -71
- data/lib/applitools/calabash/target.rb +0 -69
- data/lib/applitools/calabash/utils.rb +0 -74
- data/lib/applitools/calabash_steps.rb +0 -16
- data/lib/applitools/capybara/capybara_settings.rb +0 -25
- data/lib/applitools/capybara/driver.rb +0 -39
- data/lib/applitools/rspec/target_matcher.rb +0 -25
- data/lib/applitools/universal_sdk/executable_finder.rb +0 -57
- data/lib/applitools/universal_sdk/universal_server_control.rb +0 -79
- data/lib/applitools/version.rb +0 -8
- data/lib/eyes_consts.rb +0 -4
- data/lib/eyes_rspec.rb +0 -4
@@ -1,240 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Applitools
|
4
|
-
module Appium
|
5
|
-
class Target < Applitools::Selenium::Target
|
6
|
-
|
7
|
-
def ignore(*args)
|
8
|
-
if args.empty?
|
9
|
-
reset_ignore
|
10
|
-
else
|
11
|
-
value = convert_to_universal(args)
|
12
|
-
value = { type: args[0], selector: args[1] } if value.nil?
|
13
|
-
# value = value[:selector] if value.is_a?(Hash) && (value[:type].to_s === 'id') && !is_a?(Applitools::Appium::Target)
|
14
|
-
ignored_regions << value
|
15
|
-
end
|
16
|
-
self
|
17
|
-
end
|
18
|
-
|
19
|
-
def region(*args)
|
20
|
-
value = convert_to_universal(args)
|
21
|
-
value = { type: args[0], selector: args[1] } if value.nil?
|
22
|
-
# value = value[:selector] if value.is_a?(Hash) && (value[:type].to_s === 'id') && !is_a?(Applitools::Appium::Target)
|
23
|
-
self.region_to_check = value
|
24
|
-
self.coordinate_type = Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative]
|
25
|
-
options[:timeout] = nil
|
26
|
-
reset_ignore
|
27
|
-
reset_floating
|
28
|
-
self
|
29
|
-
end
|
30
|
-
|
31
|
-
def webview(value = true)
|
32
|
-
options[:webview] = value.is_a?(String) ? value : !!value
|
33
|
-
# options[:stitch_content] = false if options[:stitch_content].nil?
|
34
|
-
self
|
35
|
-
end
|
36
|
-
|
37
|
-
# class Target
|
38
|
-
# include Applitools::FluentInterface
|
39
|
-
# attr_accessor :region_to_check, :options, :ignored_regions, :floating_regions, :layout_regions, :content_regions, :strict_regions, :accessibility_regions
|
40
|
-
#
|
41
|
-
# class << self
|
42
|
-
# def window
|
43
|
-
# new
|
44
|
-
# end
|
45
|
-
#
|
46
|
-
# def region(*args)
|
47
|
-
# new.region(*args)
|
48
|
-
# end
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# def initialize
|
52
|
-
# self.region_to_check = proc { Applitools::Region::EMPTY }
|
53
|
-
# self.ignored_regions = []
|
54
|
-
# self.floating_regions = []
|
55
|
-
# self.layout_regions = []
|
56
|
-
# self.content_regions = []
|
57
|
-
# self.strict_regions = []
|
58
|
-
# self.accessibility_regions = []
|
59
|
-
# self.options = {}
|
60
|
-
# end
|
61
|
-
#
|
62
|
-
# def region(*args)
|
63
|
-
# self.region_to_check = case args.first
|
64
|
-
# when ::Selenium::WebDriver::Element
|
65
|
-
# proc { args.first }
|
66
|
-
# else
|
67
|
-
# proc do |driver|
|
68
|
-
# driver.find_element(*args)
|
69
|
-
# end
|
70
|
-
# end
|
71
|
-
# self
|
72
|
-
# end
|
73
|
-
#
|
74
|
-
# def ignore(*args)
|
75
|
-
# requested_padding = if args.last.is_a? Applitools::PaddingBounds
|
76
|
-
# args.pop
|
77
|
-
# else
|
78
|
-
# Applitools::PaddingBounds::ZERO_PADDING
|
79
|
-
# end
|
80
|
-
# ignored_regions << case (first_argument = args.first)
|
81
|
-
# when ::Selenium::WebDriver::Element
|
82
|
-
# proc do
|
83
|
-
# Applitools::Region
|
84
|
-
# .from_location_size(first_argument.location, first_argument.size)
|
85
|
-
# .padding(requested_padding)
|
86
|
-
# end
|
87
|
-
# when Applitools::Region
|
88
|
-
# result = first_argument.padding(requested_padding)
|
89
|
-
# if Applitools::Appium::Utils.ios?(Applitools::Appium::Driver::AppiumLib)
|
90
|
-
# def result.converted?
|
91
|
-
# true
|
92
|
-
# end
|
93
|
-
# end
|
94
|
-
# result
|
95
|
-
# else
|
96
|
-
# proc do |driver|
|
97
|
-
# element = driver.find_element(*args)
|
98
|
-
# Applitools::Region
|
99
|
-
# .from_location_size(element.location, element.size)
|
100
|
-
# .padding(requested_padding)
|
101
|
-
# end
|
102
|
-
# end
|
103
|
-
# self
|
104
|
-
# end
|
105
|
-
#
|
106
|
-
# def floating(*args)
|
107
|
-
# value = case args.first
|
108
|
-
# when Applitools::FloatingRegion
|
109
|
-
# args.first
|
110
|
-
# when Applitools::Region
|
111
|
-
# result = Applitools::FloatingRegion.any(*args)
|
112
|
-
# if Applitools::Appium::Utils.ios?(Applitools::Appium::Driver::AppiumLib)
|
113
|
-
# def result.converted?
|
114
|
-
# true
|
115
|
-
# end
|
116
|
-
# end
|
117
|
-
# result
|
118
|
-
# when ::Selenium::WebDriver::Element
|
119
|
-
# args_dup = args.dup
|
120
|
-
# Applitools::FloatingRegion.any(*args_dup)
|
121
|
-
# else
|
122
|
-
# proc do |driver|
|
123
|
-
# args_dup = args.dup
|
124
|
-
# region = driver.find_element(args_dup.shift, args_dup.shift)
|
125
|
-
# Applitools::FloatingRegion.any(
|
126
|
-
# region, *args_dup
|
127
|
-
# )
|
128
|
-
# end
|
129
|
-
# end
|
130
|
-
# floating_regions << value
|
131
|
-
# self
|
132
|
-
# end
|
133
|
-
#
|
134
|
-
# def layout
|
135
|
-
# return match_level(Applitools::MatchLevel::LAYOUT) if args.empty?
|
136
|
-
# region = process_region(*args)
|
137
|
-
# layout_regions << region
|
138
|
-
# self
|
139
|
-
#
|
140
|
-
# end
|
141
|
-
#
|
142
|
-
# def content(*args)
|
143
|
-
# return match_level(Applitools::MatchLevel::CONTENT) if args.empty?
|
144
|
-
# region = process_region(*args)
|
145
|
-
# content_regions << region
|
146
|
-
# self
|
147
|
-
# end
|
148
|
-
#
|
149
|
-
# def strict(*args)
|
150
|
-
# return match_level(Applitools::MatchLevel::STRICT) if args.empty?
|
151
|
-
# region = process_region(*args)
|
152
|
-
# strict_regions << region
|
153
|
-
# self
|
154
|
-
# end
|
155
|
-
#
|
156
|
-
# def exact(*args)
|
157
|
-
# match_level(Applitools::MatchLevel::EXACT, *args)
|
158
|
-
# end
|
159
|
-
#
|
160
|
-
# def accessibility(*args)
|
161
|
-
# options = Applitools::Utils.extract_options! args
|
162
|
-
# unless options[:type]
|
163
|
-
# raise Applitools::EyesError,
|
164
|
-
# 'You should call Target.accessibility(region, type: type). The region_type option is required'
|
165
|
-
# end
|
166
|
-
# unless Applitools::AccessibilityRegionType.enum_values.include?(options[:type])
|
167
|
-
# raise Applitools::EyesIllegalArgument,
|
168
|
-
# "The region type should be one of [#{Applitools::AccessibilityRegionType.enum_values.join(', ')}]"
|
169
|
-
# end
|
170
|
-
#
|
171
|
-
# accessibility_regions << case args.first
|
172
|
-
# when ::Selenium::WebDriver::Element
|
173
|
-
# element = args.first
|
174
|
-
# Applitools::AccessibilityRegion.new(
|
175
|
-
# element,
|
176
|
-
# options[:type]
|
177
|
-
# )
|
178
|
-
# when Applitools::Region
|
179
|
-
# result = Applitools::AccessibilityRegion.new(
|
180
|
-
# args.first, options[:type]
|
181
|
-
# )
|
182
|
-
# if Applitools::Appium::Utils.ios?(Applitools::Appium::Driver::AppiumLib)
|
183
|
-
# def result.converted?
|
184
|
-
# true
|
185
|
-
# end
|
186
|
-
# end
|
187
|
-
# result
|
188
|
-
# when String
|
189
|
-
# proc do |driver|
|
190
|
-
# element = driver.find_element(name_or_id: args.first)
|
191
|
-
# Applitools::AccessibilityRegion.new(
|
192
|
-
# element,
|
193
|
-
# options[:type]
|
194
|
-
# )
|
195
|
-
# end
|
196
|
-
# else
|
197
|
-
# proc do |driver|
|
198
|
-
# elements = driver.find_elements(*args)
|
199
|
-
# elements.map do |e|
|
200
|
-
# Applitools::AccessibilityRegion.new(
|
201
|
-
# e,
|
202
|
-
# options[:type]
|
203
|
-
# )
|
204
|
-
# end
|
205
|
-
# end
|
206
|
-
# end
|
207
|
-
# self
|
208
|
-
# end
|
209
|
-
#
|
210
|
-
# def finalize
|
211
|
-
# self
|
212
|
-
# end
|
213
|
-
#
|
214
|
-
# private
|
215
|
-
#
|
216
|
-
# def process_region(*args)
|
217
|
-
# r = args.first
|
218
|
-
# case r
|
219
|
-
# when ::Selenium::WebDriver::Element
|
220
|
-
# proc do |driver|
|
221
|
-
# Applitools::Region.from_location_size(r.location, r.size)
|
222
|
-
# end
|
223
|
-
# when Applitools::Region
|
224
|
-
# if Applitools::Appium::Utils.ios?(Applitools::Appium::Driver::AppiumLib)
|
225
|
-
# def r.converted?
|
226
|
-
# true
|
227
|
-
# end
|
228
|
-
# end
|
229
|
-
# r
|
230
|
-
# else
|
231
|
-
# proc do |driver|
|
232
|
-
# element = driver.find_element(*args)
|
233
|
-
# Applitools::Region.from_location_size(element.location, element.size)
|
234
|
-
# end
|
235
|
-
# end
|
236
|
-
# end
|
237
|
-
#
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
|
3
|
-
module Applitools::Appium
|
4
|
-
module Utils
|
5
|
-
include Applitools::Utils::EyesSeleniumUtils
|
6
|
-
extend self
|
7
|
-
|
8
|
-
# true if test is running on mobile device
|
9
|
-
def mobile_device?(driver)
|
10
|
-
defined?(Appium::Driver) &&
|
11
|
-
defined?(Applitools::Appium::Driver::AppiumLib) &&
|
12
|
-
Applitools::Appium::Driver::AppiumLib
|
13
|
-
end
|
14
|
-
|
15
|
-
# true if test is running on Android device
|
16
|
-
def android?(driver)
|
17
|
-
driver.respond_to?(:device_is_android?) && driver.device_is_android?
|
18
|
-
end
|
19
|
-
|
20
|
-
# true if test is running on iOS device
|
21
|
-
def ios?(driver)
|
22
|
-
driver.respond_to?(:device_is_ios?) && driver.device_is_ios?
|
23
|
-
end
|
24
|
-
|
25
|
-
# @param [Applitools::Selenium::Driver] driver
|
26
|
-
def platform_version(driver)
|
27
|
-
driver.respond_to?(:platform_version) && driver.platform_version
|
28
|
-
end
|
29
|
-
|
30
|
-
# @param [Applitools::Selenium::Driver] executor
|
31
|
-
def device_pixel_ratio(executor)
|
32
|
-
session_info = session_capabilities(executor)
|
33
|
-
return session_info['pixelRatio'].to_f if session_info['pixelRatio']
|
34
|
-
1
|
35
|
-
end
|
36
|
-
|
37
|
-
def status_bar_height(executor)
|
38
|
-
session_info = session_capabilities(executor)
|
39
|
-
return session_info['statBarHeight'].to_i if session_info['statBarHeight']
|
40
|
-
0
|
41
|
-
end
|
42
|
-
|
43
|
-
def viewport_rect(executor)
|
44
|
-
session_info = session_capabilities(executor)
|
45
|
-
return session_info['viewportRect'] if session_info['viewportRect']
|
46
|
-
{
|
47
|
-
'left' => 0,
|
48
|
-
'top' => 0,
|
49
|
-
'width' => 0,
|
50
|
-
'height' => 0
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
def session_capabilities(executor)
|
55
|
-
executor.session_capabilities if executor.respond_to? :session_capabilities
|
56
|
-
end
|
57
|
-
|
58
|
-
def current_scroll_position(driver)
|
59
|
-
super
|
60
|
-
rescue
|
61
|
-
Applitools::Location::TOP_LEFT
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Applitools
|
4
|
-
module Calabash
|
5
|
-
class CalabashElement
|
6
|
-
extend Forwardable
|
7
|
-
attr_reader :original_element, :element_query
|
8
|
-
def_delegators :@original_element, :[], :keys, :values
|
9
|
-
|
10
|
-
def initialize(element, element_query)
|
11
|
-
raise Applitools::EyesIllegalArgument, "Invalid element passed! (#{element})" unless valid_element?(element)
|
12
|
-
@original_element = element
|
13
|
-
@element_query = element_query
|
14
|
-
end
|
15
|
-
|
16
|
-
def left
|
17
|
-
self['rect']['x']
|
18
|
-
end
|
19
|
-
|
20
|
-
alias x left
|
21
|
-
|
22
|
-
def top
|
23
|
-
self['rect']['y']
|
24
|
-
end
|
25
|
-
|
26
|
-
alias y top
|
27
|
-
|
28
|
-
def width
|
29
|
-
self['rect']['width']
|
30
|
-
end
|
31
|
-
|
32
|
-
def height
|
33
|
-
self['rect']['height']
|
34
|
-
end
|
35
|
-
|
36
|
-
def location
|
37
|
-
Applitools::Location.from_struct(self)
|
38
|
-
end
|
39
|
-
|
40
|
-
def size
|
41
|
-
Applitools::RectangleSize.from_struct(self)
|
42
|
-
end
|
43
|
-
|
44
|
-
def region
|
45
|
-
Applitools::Region.from_location_size(location, size)
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_s
|
49
|
-
@original_element
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def valid_element?(element)
|
55
|
-
result = true
|
56
|
-
result &&= element.is_a?(Hash)
|
57
|
-
result &&= element.key?('rect')
|
58
|
-
result &&= (rect = element['rect']).is_a?(Hash)
|
59
|
-
result &&= (%w(height width y x center_x center_y) - rect.keys).empty?
|
60
|
-
result
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Applitools
|
4
|
-
module Calabash
|
5
|
-
class CalabashScreenshotProvider
|
6
|
-
WAIT_BEFORE_SCREENSHOT = 1
|
7
|
-
attr_reader :density, :context, :debug_screenshot_provider
|
8
|
-
|
9
|
-
def initialize(_options = {})
|
10
|
-
@density = 1
|
11
|
-
end
|
12
|
-
|
13
|
-
def with_density(value)
|
14
|
-
@density = value
|
15
|
-
self
|
16
|
-
end
|
17
|
-
|
18
|
-
def using_context(value)
|
19
|
-
@context = value
|
20
|
-
self
|
21
|
-
end
|
22
|
-
|
23
|
-
def with_debug_screenshot_provider(value)
|
24
|
-
Applitools::ArgumentGuard.is_a?(
|
25
|
-
value,
|
26
|
-
'debug_screenshot_provider',
|
27
|
-
Applitools::DebugScreenshotProvider
|
28
|
-
)
|
29
|
-
@debug_screenshot_provider = value
|
30
|
-
self
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def save_debug_screenshot(screenshot, suffix)
|
36
|
-
suffix = suffix.join('_') if suffix.respond_to? :join
|
37
|
-
debug_screenshot_provider.save(screenshot, suffix || '') if debug_screenshot_provider
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class AndroidScreenshotProvider < CalabashScreenshotProvider
|
42
|
-
include Singleton
|
43
|
-
|
44
|
-
def capture_screenshot(options = {})
|
45
|
-
sleep WAIT_BEFORE_SCREENSHOT
|
46
|
-
result = nil
|
47
|
-
# Applitools::Calabash::Utils.using_screenshot(context) do |screenshot_path|
|
48
|
-
# screenshot = ::ChunkyPNG::Image.from_file(screenshot_path)
|
49
|
-
# save_debug_screenshot(screenshot, ['original', options[:debug_suffix]])
|
50
|
-
# viewport_size = Applitools::Calabash::EyesSettings.instance.viewport_size
|
51
|
-
# screenshot.crop!(0, 0, viewport_size[:width], viewport_size[:height])
|
52
|
-
# save_debug_screenshot(screenshot, ['cropped', options[:debug_suffix]])
|
53
|
-
# result = Applitools::Calabash::EyesCalabashAndroidScreenshot.new(
|
54
|
-
# Applitools::Screenshot.from_image(
|
55
|
-
# screenshot
|
56
|
-
# ),
|
57
|
-
# density: density
|
58
|
-
# )
|
59
|
-
# end
|
60
|
-
result
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
class IosScreenshotProvider < CalabashScreenshotProvider
|
65
|
-
include Singleton
|
66
|
-
def capture_screenshot(options = {})
|
67
|
-
sleep WAIT_BEFORE_SCREENSHOT
|
68
|
-
result = nil
|
69
|
-
# Applitools::Calabash::Utils.using_screenshot(context) do |screenshot_path|
|
70
|
-
# screenshot = ::ChunkyPNG::Image.from_file(screenshot_path)
|
71
|
-
# save_debug_screenshot(screenshot, options[:debug_suffix])
|
72
|
-
# result = Applitools::Calabash::EyesCalabashIosScreenshot.new(
|
73
|
-
# Applitools::Screenshot.from_image(
|
74
|
-
# screenshot
|
75
|
-
# ),
|
76
|
-
# scale_factor: density
|
77
|
-
# )
|
78
|
-
# end
|
79
|
-
result
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Applitools
|
4
|
-
module Calabash
|
5
|
-
module EnvironmentDetector
|
6
|
-
extend self
|
7
|
-
|
8
|
-
def android?
|
9
|
-
return true if defined?(::Calabash::Android) == 'constant'
|
10
|
-
false
|
11
|
-
end
|
12
|
-
|
13
|
-
def ios?
|
14
|
-
return true if defined?(::Calabash::Cucumber) == 'constant'
|
15
|
-
false
|
16
|
-
end
|
17
|
-
|
18
|
-
def current_environment
|
19
|
-
return :android if android?
|
20
|
-
return :ios if ios?
|
21
|
-
raise Applitools::EyesError, 'No calabash environment found!'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,194 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
|
3
|
-
module Applitools
|
4
|
-
module Calabash
|
5
|
-
class Eyes < Applitools::EyesBase
|
6
|
-
attr_accessor :device_pixel_ratio, :full_page_capture_algorithm, :base_agent_id, :title,
|
7
|
-
:debug_screenshots, :debug_screenshot_provider, :tag_for_debug
|
8
|
-
attr_reader :context
|
9
|
-
|
10
|
-
def initialize(server_url = Applitools::Connectivity::ServerConnector::DEFAULT_SERVER_URL)
|
11
|
-
super
|
12
|
-
self.runner = Applitools::ClassicRunner.new
|
13
|
-
self.base_agent_id = "eyes.calabash.ruby/#{Applitools::VERSION}".freeze
|
14
|
-
self.debug_screenshots = false
|
15
|
-
self.debug_screenshot_provider = Applitools::DebugScreenshotProvider.new
|
16
|
-
.tag_access { tag_for_debug }
|
17
|
-
.debug_flag_access { debug_screenshots }
|
18
|
-
end
|
19
|
-
|
20
|
-
def open(options = {})
|
21
|
-
Applitools::ArgumentGuard.hash options, 'open(options)', [:app_name, :test_name]
|
22
|
-
open_base options
|
23
|
-
end
|
24
|
-
|
25
|
-
def check(*args)
|
26
|
-
args.compact!
|
27
|
-
case (first_arg = args.shift)
|
28
|
-
when String
|
29
|
-
name = first_arg
|
30
|
-
target = args.shift
|
31
|
-
when Applitools::Selenium::Target
|
32
|
-
target = first_arg
|
33
|
-
when Hash
|
34
|
-
target = first_arg[:target]
|
35
|
-
name = first_arg[:name] || first_arg[:tag]
|
36
|
-
end
|
37
|
-
|
38
|
-
self.tag_for_debug = get_tag_for_debug(name)
|
39
|
-
check_it(name, target, Applitools::MatchWindowData.new(default_match_settings))
|
40
|
-
end
|
41
|
-
|
42
|
-
def inferred_environment
|
43
|
-
return @inferred_environment unless @inferred_environment.nil?
|
44
|
-
return unless device_pixel_ratio
|
45
|
-
"device pixel ratio: #{device_pixel_ratio}"
|
46
|
-
end
|
47
|
-
|
48
|
-
def add_context(value)
|
49
|
-
@context = value
|
50
|
-
end
|
51
|
-
|
52
|
-
def remove_context
|
53
|
-
@context = nil
|
54
|
-
end
|
55
|
-
|
56
|
-
def capture_screenshot
|
57
|
-
return screenshot_provider.capture_screenshot(debug_suffix: tag_for_debug) unless full_page_capture_algorithm
|
58
|
-
full_page_capture_algorithm.get_stitched_region
|
59
|
-
end
|
60
|
-
|
61
|
-
def screenshot_provider
|
62
|
-
env = Applitools::Calabash::EnvironmentDetector.current_environment
|
63
|
-
case env
|
64
|
-
when :android
|
65
|
-
Applitools::Calabash::AndroidScreenshotProvider.instance.with_density(device_pixel_ratio)
|
66
|
-
.using_context(context)
|
67
|
-
.with_debug_screenshot_provider(debug_screenshot_provider)
|
68
|
-
when :ios
|
69
|
-
Applitools::Calabash::IosScreenshotProvider.instance.with_density(device_pixel_ratio)
|
70
|
-
.using_context(context)
|
71
|
-
.with_debug_screenshot_provider(debug_screenshot_provider)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def check_it(name, target, match_window_data)
|
76
|
-
Applitools::ArgumentGuard.not_nil(name, 'name')
|
77
|
-
|
78
|
-
logger.info 'Full element requested' if target.options[:stitch_content]
|
79
|
-
|
80
|
-
self.full_page_capture_algorithm = target.options[:stitch_content] &&
|
81
|
-
get_full_page_capture_algorithm(target.region_to_check)
|
82
|
-
|
83
|
-
region_provider = if full_page_capture_algorithm
|
84
|
-
entire_screenshot_region
|
85
|
-
else
|
86
|
-
get_region_provider(target)
|
87
|
-
end
|
88
|
-
|
89
|
-
match_window_data.tag = name
|
90
|
-
match_window_data.read_target(target, nil)
|
91
|
-
|
92
|
-
self.viewport_size = Applitools::Calabash::EyesSettings.instance.viewport_size if viewport_size.nil?
|
93
|
-
|
94
|
-
if match_window_data.is_a? Applitools::MatchSingleCheckData
|
95
|
-
return check_single_base(
|
96
|
-
region_provider,
|
97
|
-
target.options[:timeout] || Applitools::EyesBase::USE_DEFAULT_TIMEOUT,
|
98
|
-
match_window_data
|
99
|
-
)
|
100
|
-
end
|
101
|
-
|
102
|
-
check_window_base(
|
103
|
-
region_provider,
|
104
|
-
target.options[:timeout] || Applitools::EyesBase::USE_DEFAULT_TIMEOUT,
|
105
|
-
match_window_data
|
106
|
-
)
|
107
|
-
end
|
108
|
-
|
109
|
-
def get_region_provider(target)
|
110
|
-
if (region_to_check = target.region_to_check).nil?
|
111
|
-
entire_screenshot_region
|
112
|
-
else
|
113
|
-
region_for_element(region_to_check)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def get_app_output_with_screenshot(*args)
|
118
|
-
result = super(*args, &:scale_it!)
|
119
|
-
self.screenshot_url = nil
|
120
|
-
result
|
121
|
-
end
|
122
|
-
|
123
|
-
def entire_screenshot_region
|
124
|
-
Object.new.tap do |prov|
|
125
|
-
prov.instance_eval do
|
126
|
-
define_singleton_method :region do
|
127
|
-
Applitools::Region::EMPTY
|
128
|
-
end
|
129
|
-
|
130
|
-
define_singleton_method :coordinate_type do
|
131
|
-
nil
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def region_for_element(region_to_check)
|
138
|
-
Object.new.tap do |prov|
|
139
|
-
prov.instance_eval do
|
140
|
-
define_singleton_method :region do
|
141
|
-
case region_to_check
|
142
|
-
when Applitools::Calabash::CalabashElement
|
143
|
-
region_to_check.region
|
144
|
-
when Applitools::Region
|
145
|
-
region_to_check
|
146
|
-
else
|
147
|
-
raise Applitools::EyesError, "Incompatible region type: #{region_to_check.class}"
|
148
|
-
end
|
149
|
-
# region_to_check.respond_to?(:region) ? region_to_check.region : region_to_check
|
150
|
-
end
|
151
|
-
define_singleton_method :coordinate_type do
|
152
|
-
Applitools::Calabash::EyesCalabashScreenshot::DRIVER
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def vp_size
|
159
|
-
viewport_size
|
160
|
-
end
|
161
|
-
|
162
|
-
def vp_size=(value, skip_check_if_open = false)
|
163
|
-
unless skip_check_if_open || open?
|
164
|
-
raise Applitools::EyesNotOpenException.new 'set_viewport_size: Eyes not open!'
|
165
|
-
end
|
166
|
-
Applitools::ArgumentGuard.not_nil 'value', value
|
167
|
-
@viewport_size = Applitools::RectangleSize.for value
|
168
|
-
end
|
169
|
-
|
170
|
-
alias get_viewport_size vp_size
|
171
|
-
alias set_viewport_size vp_size=
|
172
|
-
|
173
|
-
def get_full_page_capture_algorithm(element)
|
174
|
-
logger.info "Trying to get full page capture algorithm for element #{element}..."
|
175
|
-
environment = Applitools::Calabash::EnvironmentDetector.current_environment
|
176
|
-
element_class = Applitools::Calabash::Utils.send("grub_#{environment}_class_name", context, element).first
|
177
|
-
logger.info "Trying to get FullPageCaptureAlgorithm for #{element_class}..."
|
178
|
-
algo = Applitools::Calabash::FullPageCaptureAlgorithm.get_algorithm_class(environment, element_class)
|
179
|
-
if algo
|
180
|
-
logger.info "Using #{algo}"
|
181
|
-
algo = algo.new(screenshot_provider, element, debug_screenshot_provider: debug_screenshot_provider)
|
182
|
-
else
|
183
|
-
logger.info "FullPageCaptureAlgorithm for #{element_class} not found. Continue with :check_region instead"
|
184
|
-
end
|
185
|
-
algo
|
186
|
-
end
|
187
|
-
|
188
|
-
def get_tag_for_debug(name)
|
189
|
-
return "#{app_name} #{test_name}" if name.empty?
|
190
|
-
"#{app_name} #{test_name} - #{name}"
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|