eyes_selenium 1.36.0 → 1.37.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTVkZmRmNjA5MWI2NWVjNzliNTI1NDY5NDJmMmQxYmMyOGNjZWIxNA==
4
+ ZjM5ZGYyZTdlNDc2YjY4OTgzMDJjZTU4NDQyNGYwYTkwYmNhZDkwMA==
5
5
  data.tar.gz: !binary |-
6
- ZTdlMmEyNDFjYTllNzk3YjVkMGM2YjE0OGQ3YzliODU4MDk2N2UyNw==
6
+ MjZmNjJmMDVlYjQ1YTY4NWZkMjNjZWRlYjc1YjViNmE0ZGNiMDhiNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTM0MzYyZmMzYzk0MzU1MzBmYTMyZjVhMmIzNmQyMzc0YmY4NDVkZGEyZGFm
10
- ZjUwNjhjYzUwMTFlM2ViYzY3YjM3N2M5MjQ0NWIxMGY5ZjBiODZiYjc2NDNl
11
- YTcwZDJhNzdlYmJjZGZkMWRmZmEzNjVhZWI4YWRmYTEzMTRkMTQ=
9
+ MGM5MjBkMWI3YTgwNzRjNjNkOGZjNGIzMTczNTMyNDYxZmEwZDk0MjEyZjZk
10
+ NDI3NWI5NTJiN2NkOGY0NjA4NjA5MjA4MThmZDA4ODZjN2Y1YWRjNzkyM2M3
11
+ ODhhOGMxMjgzYTQ4NzYzNjYxNDYyMDg2N2I2NGFjYTg5ZTIxNTk=
12
12
  data.tar.gz: !binary |-
13
- ZWU2Yjk4YzNlOTZlZDVjNWNjNzA0Njc1ZGI1MjBhODU1MzhmMzI5ODNiNzhj
14
- NTUyYWRlNWRiMzQyMmE0MWEzZjRlZWU5NGZiM2NkZTgwYWQxMGE1MzAwZTUx
15
- ZjBjN2MzZWIwZWEzMWQ5NGNjODg5ZmFkMzllMDQ0ZDY4NTE1Y2I=
13
+ ZmMyNzUwZmVmYmMzNzk2YTIzZjc0Yjg3NGMzY2Y0NWJjYTk4ZmM4MGFkMjRk
14
+ MTgxZDc2MGE3NzMzYzFkY2MzMWUzMTQ3ZjAyMmVmOTI5NWZjMjk2NDA0MzY0
15
+ NzllZmQyMTg4MGYyNzg1NWM0NGNhYzA5ZGY1ZjBhMGY4NDZmNWI=
@@ -1,6 +1,6 @@
1
1
  require 'eyes_selenium'
2
2
 
3
- Applitools::Eyes.config[:apikey] = 'YOUR_API_KEY'
3
+ Applitools::Eyes.api_key = 'YOUR_API_KEY'
4
4
 
5
5
  ##
6
6
  # Based on Appium example: https://github.com/appium/appium/blob/master/sample-code/examples/ruby/
@@ -5,7 +5,7 @@ class Applitools::Eyes
5
5
  DEFAULT_EYES_SERVER = 'https://eyes.applitools.com'
6
6
 
7
7
  class << self
8
- attr_accessor :config, :api_key
8
+ attr_accessor :api_key
9
9
 
10
10
  def log_handler=(handler)
11
11
  EyesLogger.log_handler = handler
@@ -13,7 +13,6 @@ class Applitools::Eyes
13
13
  end
14
14
 
15
15
  # Class instance variables (static variables)
16
- @config = {}
17
16
  @api_key = nil
18
17
 
19
18
  private
@@ -26,10 +25,6 @@ class Applitools::Eyes
26
25
  attr_accessor :match_timeout, :batch, :host_os, :host_app, :branch_name, :parent_branch_name, :user_inputs,
27
26
  :save_new_tests, :save_failed_tests
28
27
 
29
- def config
30
- self.class.config
31
- end
32
-
33
28
  def api_key
34
29
  self.class.api_key
35
30
  end
@@ -51,11 +46,6 @@ class Applitools::Eyes
51
46
 
52
47
  return if disabled?
53
48
 
54
- # TODO Remove this when possible. Allows setting API key using "config" for backwards compatibility.
55
- self.class.api_key ||= config[:apikey]
56
-
57
- raise 'Please supply an apikey: Eyes.config[:apikey] = ...' unless api_key
58
-
59
49
  @user_inputs = []
60
50
  server_url = params.fetch(:server_url, DEFAULT_EYES_SERVER)
61
51
  @agent_connector = Applitools::AgentConnector.new(server_url, AGENT_ID, api_key)
@@ -70,12 +60,20 @@ class Applitools::Eyes
70
60
  @driver = get_driver(params)
71
61
  return driver if disabled?
72
62
 
73
- if driver.nil? || !driver.is_a?(Selenium::WebDriver::Driver)
74
- raise Applitools::EyesError.new('driver/browser must be a valid Selenium webdriver')
63
+ if api_key.nil?
64
+ #noinspection RubyQuotedStringsInspection
65
+ raise Applitools::EyesError.new("API key not set! Log in to https://applitools.com to obtain your" +
66
+ " API Key and use 'api_key' to set it.")
67
+ end
68
+
69
+ if driver.is_a?(Selenium::WebDriver::Driver)
70
+ @driver = Applitools::Driver.new(self, {driver: driver})
71
+ else
72
+ unless driver.is_a?(Applitools::Driver)
73
+ raise Applitools::EyesError.new("Driver is not a Selenium::WebDriver::Driver (#{driver.class.name})")
74
+ end
75
75
  end
76
76
 
77
- @driver = Applitools::Driver.new(self, {driver: driver})
78
-
79
77
  if open?
80
78
  abort_if_not_closed
81
79
  msg = 'a test is already running'
@@ -122,41 +120,53 @@ class Applitools::Eyes
122
120
  check_region_(Applitools::Region::EMPTY, tag)
123
121
  end
124
122
 
125
- def close
123
+ def close(raise_ex=true)
126
124
  return if disabled?
127
125
  @is_open = false
128
126
 
129
127
  # if there's no running session, the test was never started (never reached checkWindow)
130
- return Applitools::TestResults.new if !session
128
+ if !session
129
+ EyesLogger.debug 'close(): Server session was not started'
130
+ EyesLogger.info 'close(): --- Empty test ended.'
131
+ return Applitools::TestResults.new
132
+ end
131
133
 
132
134
  session_results_url = session.url
133
135
  new_session = session.new_session?
136
+ EyesLogger.debug "close(): Ending server session..."
134
137
  save = (new_session && save_new_tests) || (!new_session && save_failed_tests)
135
138
  results = agent_connector.stop_session(session, false, save)
139
+ results.is_new = new_session
140
+ results.url = session_results_url
141
+ EyesLogger.debug "close(): #{results}"
142
+
136
143
  self.session = nil
144
+
137
145
  if new_session
138
- if save
139
- instructions = "Test was automatically accepted. You can review it at #{session_results_url}"
140
- else
141
- instructions = "Please approve the new baseline at #{session_results_url}"
142
- end
146
+ instructions = "Please approve the new baseline at #{session_results_url}"
143
147
  EyesLogger.info "--- New test ended. #{instructions}"
144
- message = "' #{session_start_info.scenario_id_or_name} of"\
148
+ if raise_ex
149
+ message = "' #{session_start_info.scenario_id_or_name} of"\
145
150
  " #{session_start_info.app_id_or_name}. #{instructions}"
146
- raise Applitools::NewTestError.new(message, results)
147
- elsif 0 < results.mismatches || 0 < results.missing
148
- if save
149
- instructions = "Test was automatically accepted. You can review it at #{session_results_url}"
150
- else
151
- instructions = "Test failed. You can review it at #{session_results_url}"
151
+ raise Applitools::NewTestError.new(message, results)
152
+ end
153
+ return results
154
+ end
155
+
156
+ if !results.is_passed
157
+ # Test failed
158
+ EyesLogger.info "--- Failed test ended. See details at #{session_results_url}"
159
+ if raise_ex
160
+ message = "'#{session_start_info.scenario_id_or_name}' of"\
161
+ "#{session_start_info.app_id_or_name}''. see details at #{session_results_url}"
162
+ raise Applitools::TestFailedError.new(message, results)
152
163
  end
153
- EyesLogger.info "--- Failed test ended. #{instructions}"
154
- message = "' #{session_start_info.scenario_id_or_name} of"\
155
- " #{session_start_info.app_id_or_name}'. #{instructions}"
156
- raise Applitools::TestFailedError.new(message, results)
164
+ return results
157
165
  end
158
166
 
167
+ # Test passed
159
168
  EyesLogger.info "--- Test passed. See details at #{session_results_url}"
169
+ results
160
170
  end
161
171
 
162
172
  ## Use this method to perform seamless testing with selenium through eyes driver.
@@ -1,6 +1,7 @@
1
1
  class Applitools::TestResults
2
+ attr_accessor :is_new, :url
2
3
  attr_reader :steps, :matches, :mismatches, :missing, :exact_matches, :strict_matches,
3
- :content_matches, :layout_matches, :none_matches
4
+ :content_matches, :layout_matches, :none_matches, :is_passed
4
5
  def initialize(steps=0, matches=0, mismatches=0, missing=0,
5
6
  exact_matches=0, strict_matches=0, content_matches=0,
6
7
  layout_matches=0, none_matches=0)
@@ -13,9 +14,19 @@ class Applitools::TestResults
13
14
  @content_matches = content_matches
14
15
  @layout_matches = layout_matches
15
16
  @none_matches = none_matches
17
+ @is_new = nil
18
+ @url = nil
19
+ end
20
+
21
+ def is_passed
22
+ !is_new && mismatches == 0 && missing ==0
16
23
  end
17
24
 
18
25
  def to_s
19
- "[ steps: #{steps}, matches: #{matches}, mismatches: #{mismatches}, missing: #{missing} ]"
26
+ is_new_str = ""
27
+ unless is_new.nil?
28
+ is_new_str = is_new ? "New test" : "Existing test"
29
+ end
30
+ "#{is_new_str} [ steps: #{steps}, matches: #{matches}, mismatches: #{mismatches}, missing: #{missing} ], URL: #{url}"
20
31
  end
21
32
  end
@@ -32,4 +32,16 @@ module EyesLogger
32
32
  @@log_handler.debug(msg)
33
33
  end
34
34
 
35
+ def self.open
36
+ if @@log_handler.respond_to?(:open)
37
+ @@log_handler.open
38
+ end
39
+ end
40
+
41
+ def self.close
42
+ if @@log_handler.respond_to?(:close)
43
+ @@log_handler.close
44
+ end
45
+ end
46
+
35
47
  end
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = '1.36.0'
2
+ VERSION = '1.37.0'
3
3
  end
data/test_script.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  require 'eyes_selenium'
6
6
  require 'logger'
7
7
 
8
- Applitools::Eyes.config[:apikey] = 'YOUR_API_KEY'
8
+ Applitools::Eyes.api_key = 'YOUR_API_KEY'
9
9
  Applitools::Eyes.log_handler = Logger.new(STDOUT)
10
10
 
11
11
  eyes = Applitools::Eyes.new
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.36.0
4
+ version: 1.37.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-05-03 00:00:00.000000000 Z
11
+ date: 2014-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver