Module: Applitools::UniversalEyesChecks

Included in:
EyesBase
Defined in:
lib/applitools/core/universal_eyes_checks.rb

Instance Method Summary collapse

Instance Method Details

#universal_check(name, target) ⇒ Applitools::MatchResult

Takes a snapshot and matches it with the expected output.

Parameters:

  • name (String)

    The name of the tag.

  • target (Applitools::Selenium::Target)

    which area of the window to check.

Returns:

Raises:

  • (Applitools::EyesNotOpenException)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/applitools/core/universal_eyes_checks.rb', line 11

def universal_check(name, target)
  return disabled_result if respond_to?(:disabled?) && disabled?

  raise Applitools::EyesNotOpenException.new('Eyes not open!') if @universal_eyes.nil?
  raise Applitools::EyesNotOpenException.new('Eyes not open') unless open?
  Applitools::EyesLogger.logger.info "#{test_name} : check(#{name}) started  ..."
  settings = get_universal_check_settings(name, target)
  image_target = settings[:image].nil? ? {} : { image: settings.delete(:image) }
  # require 'pry'
  # binding.pry
  check_result = @universal_eyes.check(settings, image_target)
  if server_error?(check_result)
    # require 'pry'
    # binding.pry
    raise Applitools::EyesError.new("Request failed: #{check_result[:message]}")
  end

  if check_result != {} && !check_result.nil?
    result = Applitools::MatchResult.new(Applitools::Utils.deep_stringify_keys(check_result[0]))

    check_fail_result_processing(name) unless result.as_expected?
  end

  logger.info 'Done!'
  result
end