eyes_selenium 1.39.0 → 1.40.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 +8 -8
- data/lib/eyes_selenium/eyes/eyes.rb +8 -7
- data/lib/eyes_selenium/eyes/match_window_task.rb +33 -13
- data/lib/eyes_selenium/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGIwYmU3YzViYzJmNWI2Mzg3NzFjZWZiYjg5OTIzMDE2NTQwODYyZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzdkZDQxZTEzMDFlYTc5YWI5Mzg3Yzk0NmNjZDYyMzhlNDlmOThkZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjA0ZTVmNzI2NjNlZjQ4Yzk1NmE0ZWJkYjUxMTM0OWY3NzcyYzRkZjg2YTVi
|
10
|
+
ODA4ZDFkNzQ2MDQ3NTMzZThmYjkyMGJmOGIwNzQxZTA5ODMxNWQyZWM1ZmRl
|
11
|
+
Mjk4OGI1NWI1NDYyY2U0NjM3OWEwNDJiOTViM2EyYjQ0N2E3YTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmY1NzY2MGViNGUwMGZmY2EwMDQ4NzM1YTZhODMyOThjM2UxY2JjOTkwMGI0
|
14
|
+
NjMwNGQ0N2Q2MDc2MjJkNGIyYjljYWY2YWVkMGFjNTUyZWIyNThhMDU5MjBi
|
15
|
+
MDVlN2U0YmI4ZTM4YWU1YmQ4Yzk0ZTQ3ZDYwNTg1YWQ2NGQwYWE=
|
@@ -99,7 +99,7 @@ class Applitools::Eyes
|
|
99
99
|
user_inputs.clear
|
100
100
|
end
|
101
101
|
|
102
|
-
def check_region(how, what, tag=nil)
|
102
|
+
def check_region(how, what, tag=nil, specific_timeout=-1)
|
103
103
|
return if disabled?
|
104
104
|
# We have to start the session if it's not started, since we want the viewport size to be set before getting the
|
105
105
|
# element's position and size
|
@@ -113,11 +113,11 @@ class Applitools::Eyes
|
|
113
113
|
location = element_to_check.location
|
114
114
|
size = element_to_check.size
|
115
115
|
region = Applitools::Region.new(location.x, location.y, size.width, size.height)
|
116
|
-
check_region_(region, tag)
|
116
|
+
check_region_(region, tag, specific_timeout)
|
117
117
|
end
|
118
118
|
|
119
|
-
def check_window(tag=nil)
|
120
|
-
check_region_(Applitools::Region::EMPTY, tag)
|
119
|
+
def check_window(tag=nil, specific_timeout=-1)
|
120
|
+
check_region_(Applitools::Region::EMPTY, tag, specific_timeout)
|
121
121
|
end
|
122
122
|
|
123
123
|
def close(raise_ex=true)
|
@@ -265,8 +265,9 @@ class Applitools::Eyes
|
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
268
|
-
def check_region_(region, tag=nil)
|
268
|
+
def check_region_(region, tag=nil, specific_timeout=-1)
|
269
269
|
return if disabled?
|
270
|
+
EyesLogger.info "check_region('#{tag}', #{specific_timeout})"
|
270
271
|
raise Applitools::EyesError.new('region cannot be nil!') if region.nil?
|
271
272
|
raise Applitools::EyesError.new('Eyes not open') if !open?
|
272
273
|
|
@@ -275,11 +276,11 @@ class Applitools::Eyes
|
|
275
276
|
self.match_window_task = Applitools::MatchWindowTask.new(self, agent_connector, session, driver, match_timeout)
|
276
277
|
end
|
277
278
|
|
278
|
-
as_expected = match_window_task.match_window(region, tag, should_match_window_run_once_on_timeout)
|
279
|
+
as_expected = match_window_task.match_window(region, specific_timeout, tag, should_match_window_run_once_on_timeout)
|
279
280
|
unless as_expected
|
280
281
|
self.should_match_window_run_once_on_timeout = true
|
281
282
|
unless session.new_session?
|
282
|
-
EyesLogger.info %(
|
283
|
+
EyesLogger.info %( mismatch #{ tag ? '' : "(#{tag})" } )
|
283
284
|
if failure_reports.to_i == Applitools::FailureReports::IMMEDIATE
|
284
285
|
raise Applitools::TestFailedError.new("Mismatch found in '#{session_start_info.scenario_id_or_name}'"\
|
285
286
|
" of '#{session_start_info.app_id_or_name}'")
|
@@ -7,29 +7,36 @@ class Applitools::MatchWindowTask
|
|
7
7
|
MATCH_INTERVAL = 0.5
|
8
8
|
AppOutput = Struct.new(:title, :screenshot64)
|
9
9
|
|
10
|
-
attr_reader :eyes, :agent_connector, :session, :driver, :
|
10
|
+
attr_reader :eyes, :agent_connector, :session, :driver, :default_retry_timeout, :last_checked_window ,:last_screenshot_bounds
|
11
11
|
|
12
12
|
public
|
13
|
-
|
14
|
-
def initialize(eyes, agent_connector, session, driver,
|
13
|
+
#noinspection RubyParameterNamingConvention
|
14
|
+
def initialize(eyes, agent_connector, session, driver, default_retry_timeout)
|
15
15
|
@eyes = eyes
|
16
16
|
@agent_connector = agent_connector
|
17
17
|
@session = session
|
18
18
|
@driver = driver
|
19
|
-
@
|
19
|
+
@default_retry_timeout = default_retry_timeout
|
20
20
|
@last_checked_window = nil # +ChunkyPNG::Canvas+
|
21
21
|
@last_screenshot_bounds = Applitools::Region::EMPTY # +Applitools::Region+
|
22
22
|
@current_screenshot = nil # +ChunkyPNG::Canvas+
|
23
23
|
end
|
24
24
|
|
25
|
-
def match_window(region, tag,run_once_after_wait=false)
|
26
|
-
|
25
|
+
def match_window(region, retry_timeout, tag,run_once_after_wait=false)
|
26
|
+
if retry_timeout < 0
|
27
|
+
retry_timeout = default_retry_timeout
|
28
|
+
end
|
29
|
+
EyesLogger.debug "Retry timeout set to: #{retry_timeout}"
|
30
|
+
start = Time.now
|
31
|
+
res = if retry_timeout.zero?
|
27
32
|
run(region, tag)
|
28
33
|
elsif run_once_after_wait
|
29
|
-
run(region, tag,
|
34
|
+
run(region, tag, retry_timeout)
|
30
35
|
else
|
31
|
-
run_with_intervals(region, tag,
|
36
|
+
run_with_intervals(region, tag, retry_timeout)
|
32
37
|
end
|
38
|
+
elapsed_time = Time.now - start
|
39
|
+
EyesLogger.debug "match_window(): Completed in #{format('%.2f', elapsed_time)} seconds"
|
33
40
|
@last_checked_window = @current_screenshot
|
34
41
|
@last_screenshot_bounds = region.empty? ? Applitools::Region.new(0, 0, last_checked_window.width, last_checked_window.height) : region
|
35
42
|
#noinspection RubyUnnecessaryReturnStatement
|
@@ -37,20 +44,33 @@ class Applitools::MatchWindowTask
|
|
37
44
|
end
|
38
45
|
|
39
46
|
def run(region, tag, wait_before_run=nil)
|
47
|
+
EyesLogger.debug "Trying matching once..."
|
40
48
|
sleep(wait_before_run) if wait_before_run
|
41
49
|
match(region, tag)
|
42
50
|
end
|
43
51
|
|
44
|
-
def run_with_intervals(region, tag,
|
52
|
+
def run_with_intervals(region, tag, retry_timeout)
|
53
|
+
# We intentionally take the first screenshot before starting the timer, to allow the page
|
54
|
+
# just a tad more time to stabilize.
|
55
|
+
EyesLogger.debug 'Matching with interval...'
|
56
|
+
data = prep_match_data(region, tag, true)
|
45
57
|
start = Time.now
|
46
|
-
|
47
|
-
|
58
|
+
as_expected = agent_connector.match_window(session, data)
|
59
|
+
EyesLogger.debug "First call result: #{as_expected}"
|
60
|
+
return true if as_expected
|
61
|
+
match_retry = Time.now - start
|
62
|
+
while match_retry < retry_timeout
|
48
63
|
sleep(MATCH_INTERVAL)
|
64
|
+
EyesLogger.debug 'Matching...'
|
49
65
|
return true if match(region, tag, true)
|
50
|
-
match_retry
|
66
|
+
match_retry = Time.now - start
|
67
|
+
EyesLogger.debug "Elapsed time: #{match_retry}"
|
51
68
|
end
|
52
69
|
## lets try one more time if we still don't have a match
|
53
|
-
match
|
70
|
+
EyesLogger.debug 'Last attempt to match...'
|
71
|
+
as_expected = match(region, tag)
|
72
|
+
EyesLogger.debug "Match result: #{as_expected}"
|
73
|
+
as_expected
|
54
74
|
end
|
55
75
|
|
56
76
|
private
|
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: 1.
|
4
|
+
version: 1.40.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-06-
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|