Module: Applitools::UniversalEyesOpen

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

Instance Method Summary collapse

Instance Method Details

#universal_open(options = {}) ⇒ Applitools::Selenium::Driver

Starts a test

Parameters:

  • options (Hash) (defaults to: {})

    options

Options Hash (options):

  • :driver (Object)

    The driver that controls the browser hosting the application under the test. (Required option)

  • :app_name (String)

    The name of the application under the test. (Required option)

  • :test_name (String)

    The test name (Required option)

  • :viewport_size (String | Hash)

    The required browser’s viewport size (i.e., the visible part of the document’s body) or nil to use the current window’s viewport.

  • :session_type (Object)

    The type of the test (e.g., standard test / visual performance test). Default value is ‘SEQUENTAL’

Returns:

  • (Applitools::Selenium::Driver)

    A wrapped web driver which enables Eyes trigger recording and frame handling



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/applitools/core/universal_eyes_open.rb', line 19

def universal_open(options = {})
  original_driver = options.delete(:driver)
  if self.class.name != 'Applitools::Images::Eyes'
    Applitools::ArgumentGuard.not_nil original_driver, 'options[:driver]'

    if respond_to?(:disabled?) && disabled?
      logger.info('Ignored')
      return original_driver
    end

    self.driver = Applitools::Selenium::SeleniumEyes.eyes_driver(original_driver, self)
  end

  update_config_from_options(options)
  universal_driver_config = driver.universal_driver_config if self.class.name != 'Applitools::Images::Eyes'
  universal_eyes_manager = runner.get_universal_eyes_manager(self)

  universal_eyes_config = Applitools::UniversalEyesConfig.new
  universal_eyes_config.from_original_sdk(self)

  # require('pry')
  # binding.pry

  @universal_eyes = universal_eyes_manager.open_eyes(universal_driver_config, universal_eyes_config.to_hash)
  raise Applitools::EyesNotOpenException.new('Eyes not open!') if @universal_eyes.nil?

  self.open = true if respond_to?(:open=, true)
  self.opened = true if respond_to?(:opened=, true)
  self.running_session = true if respond_to?(:running_session=, true)
  if self.class.name != 'Applitools::Images::Eyes'
    driver
  else
    self.open?
  end
rescue Applitools::EyesError => e
  logger.error e.message
  raise e
end

#universal_sdk_abortObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/applitools/core/universal_eyes_open.rb', line 58

def universal_sdk_abort
  if respond_to?(:disabled?) && disabled?
    logger.info "#{__method__} Ignore disabled"
    return false
  end
  # raise Applitools::EyesNotOpenException.new('Eyes not open!') if @eyes.nil?
  return if @universal_eyes.nil?
  closed_or_aborted = @universal_eyes.closed_or_aborted
  @universal_eyes.abort
  result = @universal_eyes.eyes_get_results
  result = result[0] if result.is_a?(Array)

  if result.is_a? Hash
    logger.info "---Test aborted" if !result[:message] && !result[:stack]
  else
    # TestCheckFrameInFrame_Fully_Fluent_VG\
    # require('pry')
    # binding.pry
  end
  return nil if closed_or_aborted
  Applitools::Utils.deep_stringify_keys(result)
end