eyes_selenium 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4219715fa9dc4e8d577f379654dfb8de47f4b0c3
|
4
|
+
data.tar.gz: be34d6a658b4c2da134940518a56355a4ddd2b2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c64a2308075fa442cbe9bef45d88b2873b4ea27403cc9daab82c62afcc418b3368a3d379256c0a70aee5bc262f52176428bbe158484e6900b02757d48a400fd
|
7
|
+
data.tar.gz: 7b2b468fe9957dba640ecc54e715f2a3c9f2e7a8f9af40ece6fefe07ae2ffea1bf286fb3677c434695529ca1ac2cbe2a6e48ed5fade55d4a9f1cebce4768e083
|
@@ -25,9 +25,10 @@ class Applitools::AgentConnector
|
|
25
25
|
self.class.headers 'Content-Type' => 'application/octet-stream'
|
26
26
|
json_data = data.to_hash.to_json.force_encoding('BINARY') # Notice that this does not include the screenshot
|
27
27
|
body = [json_data.length].pack('L>') + json_data + data.screenshot
|
28
|
-
|
28
|
+
EyesLogger.debug 'Sending match data...'
|
29
29
|
res = self.class.post(@endpoint_uri + "/#{session.id}", query: {apiKey: api_key}, body: body)
|
30
30
|
raise Applitools::EyesError.new('could not connect to server') if res.code != 200
|
31
|
+
EyesLogger.debug "Got response! #{res.parsed_response['asExpected']}"
|
31
32
|
res.parsed_response['asExpected']
|
32
33
|
end
|
33
34
|
|
@@ -121,20 +121,30 @@ class Applitools::Eyes
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def check_region(how, what, tag=nil, specific_timeout=-1)
|
124
|
+
EyesLogger.debug 'check_region called'
|
124
125
|
return if disabled?
|
125
126
|
# We have to start the session if it's not started, since we want the viewport size to be set before getting the
|
126
127
|
# element's position and size
|
127
128
|
raise Applitools::EyesError.new('Eyes not open') if !open?
|
128
129
|
unless session
|
130
|
+
EyesLogger.debug 'Starting session...'
|
129
131
|
start_session
|
132
|
+
EyesLogger.debug 'Done! Creating match window task...'
|
130
133
|
self.match_window_task = Applitools::MatchWindowTask.new(self, agent_connector, session, driver, match_timeout)
|
134
|
+
EyesLogger.debug 'Done!'
|
131
135
|
end
|
132
136
|
|
137
|
+
EyesLogger.debug 'Finding element...'
|
133
138
|
element_to_check = driver.find_element(how, what)
|
139
|
+
EyesLogger.debug 'Done! Getting element location...'
|
134
140
|
location = element_to_check.location
|
141
|
+
EyesLogger.debug 'Done! Getting element size...'
|
135
142
|
size = element_to_check.size
|
143
|
+
EyesLogger.debug 'Done! Creating region...'
|
136
144
|
region = Applitools::Region.new(location.x, location.y, size.width, size.height)
|
145
|
+
EyesLogger.debug 'Done! Checking region...'
|
137
146
|
check_region_(region, tag, specific_timeout)
|
147
|
+
EyesLogger.debug 'Done!'
|
138
148
|
end
|
139
149
|
|
140
150
|
def check_window(tag=nil, specific_timeout=-1)
|
@@ -288,16 +298,21 @@ class Applitools::Eyes
|
|
288
298
|
|
289
299
|
def check_region_(region, tag=nil, specific_timeout=-1)
|
290
300
|
return if disabled?
|
291
|
-
EyesLogger.info "
|
301
|
+
EyesLogger.info "check_region_('#{tag}', #{specific_timeout})"
|
292
302
|
raise Applitools::EyesError.new('region cannot be nil!') if region.nil?
|
293
303
|
raise Applitools::EyesError.new('Eyes not open') if !open?
|
294
304
|
|
295
305
|
unless session
|
306
|
+
EyesLogger.debug 'Starting session...'
|
296
307
|
start_session
|
308
|
+
EyesLogger.debug 'Done! Creating match window task...'
|
297
309
|
self.match_window_task = Applitools::MatchWindowTask.new(self, agent_connector, session, driver, match_timeout)
|
310
|
+
EyesLogger.debug 'Done!'
|
298
311
|
end
|
299
312
|
|
313
|
+
EyesLogger.debug 'Starting match task...'
|
300
314
|
as_expected = match_window_task.match_window(region, specific_timeout, tag, should_match_window_run_once_on_timeout)
|
315
|
+
EyesLogger.debug 'Match window done!'
|
301
316
|
unless as_expected
|
302
317
|
self.should_match_window_run_once_on_timeout = true
|
303
318
|
unless session.new_session?
|
@@ -44,24 +44,30 @@ class Applitools::MatchWindowTask
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def run(region, tag, wait_before_run=nil)
|
47
|
-
EyesLogger.debug
|
48
|
-
|
47
|
+
EyesLogger.debug 'Trying matching once...'
|
48
|
+
if wait_before_run
|
49
|
+
EyesLogger.debug 'waiting before run...'
|
50
|
+
sleep(wait_before_run)
|
51
|
+
EyesLogger.debug 'waiting done!'
|
52
|
+
end
|
49
53
|
match(region, tag)
|
50
54
|
end
|
51
55
|
|
52
56
|
def run_with_intervals(region, tag, retry_timeout)
|
53
57
|
# We intentionally take the first screenshot before starting the timer, to allow the page
|
54
58
|
# just a tad more time to stabilize.
|
55
|
-
EyesLogger.debug 'Matching with
|
59
|
+
EyesLogger.debug 'Matching with intervals...'
|
56
60
|
data = prep_match_data(region, tag, true)
|
57
61
|
start = Time.now
|
58
62
|
as_expected = agent_connector.match_window(session, data)
|
59
63
|
EyesLogger.debug "First call result: #{as_expected}"
|
60
64
|
return true if as_expected
|
65
|
+
EyesLogger.debug "Not as expected, performing retry (total timeout #{retry_timeout})"
|
61
66
|
match_retry = Time.now - start
|
62
67
|
while match_retry < retry_timeout
|
68
|
+
EyesLogger.debug 'Waiting before match...'
|
63
69
|
sleep(MATCH_INTERVAL)
|
64
|
-
EyesLogger.debug 'Matching...'
|
70
|
+
EyesLogger.debug 'Done! Matching...'
|
65
71
|
return true if match(region, tag, true)
|
66
72
|
match_retry = Time.now - start
|
67
73
|
EyesLogger.debug "Elapsed time: #{match_retry}"
|
@@ -84,25 +90,39 @@ class Applitools::MatchWindowTask
|
|
84
90
|
end
|
85
91
|
|
86
92
|
def prep_match_data(region, tag, ignore_mismatch)
|
93
|
+
EyesLogger.debug 'Preparing match data...'
|
87
94
|
title = eyes.title
|
95
|
+
EyesLogger.debug 'Getting screenshot...'
|
96
|
+
screenshot64 = driver.screenshot_as(:base64)
|
97
|
+
EyesLogger.debug 'Done! Decoding base64...'
|
88
98
|
# 'encoded', as in 'png'.
|
89
|
-
current_screenshot_encoded = Base64.decode64(
|
99
|
+
current_screenshot_encoded = Base64.decode64(screenshot64)
|
100
|
+
EyesLogger.debug 'Done! Creating image object from PNG...'
|
90
101
|
@current_screenshot = ChunkyPNG::Image.from_blob(current_screenshot_encoded)
|
102
|
+
EyesLogger.debug 'Done!'
|
91
103
|
# If a region was defined, we refer to the sub-image defined by the region.
|
92
104
|
unless region.empty?
|
105
|
+
EyesLogger.debug 'Calculating clipped region...'
|
93
106
|
# If the region is out of bounds, clip it
|
94
107
|
clipped_region = get_clipped_region(region, @current_screenshot)
|
95
108
|
raise Applitools::EyesError.new("Region is outside the viewport: #{region}") if clipped_region.empty?
|
109
|
+
EyesLogger.debug 'Done! Cropping region...'
|
96
110
|
@current_screenshot.crop!(clipped_region.left, clipped_region.top, clipped_region.width, clipped_region.height)
|
111
|
+
EyesLogger.debug 'Done! Creating cropped image object...'
|
97
112
|
current_screenshot_encoded = @current_screenshot.to_blob.force_encoding('BINARY')
|
113
|
+
EyesLogger.debug 'Done!'
|
98
114
|
end
|
115
|
+
EyesLogger.debug 'Compressing screenshot...'
|
99
116
|
compressed_screenshot = Applitools::Utils::ImageDeltaCompressor.compress_by_raw_blocks(@current_screenshot,
|
100
117
|
current_screenshot_encoded,
|
101
118
|
last_checked_window)
|
119
|
+
EyesLogger.debug 'Done! Creating AppOuptut...'
|
102
120
|
app_output = AppOutput.new(title, nil)
|
103
121
|
user_inputs = []
|
122
|
+
EyesLogger.debug 'Handling user inputs...'
|
104
123
|
if !last_checked_window.nil?
|
105
124
|
driver.eyes.user_inputs.each do |trigger|
|
125
|
+
EyesLogger.debug 'Handling trigger...'
|
106
126
|
if trigger.is_a?(Applitools::MouseTrigger)
|
107
127
|
updated_trigger = nil
|
108
128
|
trigger_left = trigger.control.left + trigger.location.x
|
@@ -121,6 +141,7 @@ class Applitools::MatchWindowTask
|
|
121
141
|
updated_control = Applitools::Region.new(control_left, control_top, trigger.control.width, trigger.control.height)
|
122
142
|
updated_trigger = Applitools::MouseTrigger.new(trigger.mouse_action, updated_control, Selenium::WebDriver::Point.new(trigger_left, trigger_top))
|
123
143
|
end
|
144
|
+
EyesLogger.debug 'Done with trigger!'
|
124
145
|
user_inputs << updated_trigger
|
125
146
|
else
|
126
147
|
EyesLogger.info "Trigger ignored: #{trigger} (out of bounds)"
|
@@ -133,6 +154,7 @@ class Applitools::MatchWindowTask
|
|
133
154
|
control_top = trigger.control.top - last_screenshot_bounds.top
|
134
155
|
updated_control = Applitools::Region.new(control_left, control_top, trigger.control.width, trigger.control.height)
|
135
156
|
updated_trigger = Applitools::TextTrigger.new(trigger.text, updated_control)
|
157
|
+
EyesLogger.debug 'Done with trigger!'
|
136
158
|
user_inputs << updated_trigger
|
137
159
|
else
|
138
160
|
EyesLogger.info "Trigger ignored: #{trigger} (control out of bounds)"
|
@@ -147,11 +169,17 @@ class Applitools::MatchWindowTask
|
|
147
169
|
else
|
148
170
|
EyesLogger.info 'Triggers ignored: no previous window checked'
|
149
171
|
end
|
150
|
-
|
172
|
+
EyesLogger.debug 'Creating MatchWindowData object..'
|
173
|
+
match_window_data_obj = Applitools::MatchWindowData.new(app_output, user_inputs, tag, ignore_mismatch, compressed_screenshot)
|
174
|
+
EyesLogger.debug 'Done creating MatchWindowData object!'
|
175
|
+
match_window_data_obj
|
151
176
|
end
|
152
177
|
|
153
178
|
def match(region, tag, ignore_mismatch=false)
|
179
|
+
EyesLogger.debug 'Match called...'
|
154
180
|
data = prep_match_data(region, tag, ignore_mismatch)
|
155
|
-
agent_connector.match_window(session, data)
|
181
|
+
match_result = agent_connector.match_window(session, data)
|
182
|
+
EyesLogger.debug 'Match done!'
|
183
|
+
match_result
|
156
184
|
end
|
157
185
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eyes_selenium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Applitools team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|