Class: Applitools::EyesBase

Inherits:
Object
  • Object
show all
Extended by:
Helpers, Forwardable
Includes:
MatchLevelSetter, UniversalEyesChecks, UniversalEyesOpen, UniversalNewApi
Defined in:
lib/applitools/core/eyes_base.rb

Defined Under Namespace

Classes: UserInputArray

Constant Summary collapse

USE_DEFAULT_TIMEOUT =
-1
SCREENSHOT_AS_IS =
Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is].freeze
CONTEXT_RELATIVE =
Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

abstract_attr_accessor, abstract_method, env_variable, environment_attribute, environment_variables

Methods included from MatchLevelSetter

#match_level_with_exact

Methods included from UniversalNewApi

#extract_text, #extract_text_regions, #locate

Methods included from UniversalEyesChecks

#universal_check

Methods included from UniversalEyesOpen

#universal_open, #universal_sdk_abort

Constructor Details

#initialize(*args) ⇒ EyesBase

Returns a new instance of EyesBase.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/applitools/core/eyes_base.rb', line 108

def initialize(*args)
  options = Applitools::Utils.extract_options!(args)
  self.runner = options[:runner]
  server_url = args.first
  @server_connector = Applitools::Connectivity::ServerConnector.new(server_url)
  @server_connector.obtain_agent_id do
    full_agent_id
  end
  ensure_config
  self.server_url = server_url if server_url
  self.disabled = false
  @viewport_size = nil
  self.running_session = nil
  self.save_new_tests = true
  self.save_failed_tests = false
  self.remove_session_if_matching = false
  # self.agent_id = nil
  self.last_screenshot = nil
  @user_inputs = UserInputArray.new
  self.app_output_provider = Object.new
  self.verbose_results = false
  self.failed = false
  self.results = []
  self.allow_empty_screenshot = true
  @inferred_environment = nil
  @server_scale = 0
  @server_remainder = 0
  get_app_output_method = ->(r, s) { get_app_output_with_screenshot r, s }

  app_output_provider.instance_eval do
    define_singleton_method :app_output do |r, s|
      get_app_output_method.call(r, s)
    end
  end

  # self.exact = nil
  self.match_level = Applitools::MatchLevel::STRICT
  self.server_scale = 0
  self.server_remainder = 0
  self.compare_with_parent_branch = false

  self.universal_eyes = nil # eyes.open
  self.universal_driver = nil # eyes.open
end

Instance Attribute Details

#allow_empty_screenshotObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def allow_empty_screenshot
  @allow_empty_screenshot
end

#batchObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def batch
  @batch
end

#compare_with_parent_branchObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def compare_with_parent_branch
  @compare_with_parent_branch
end

#config=(value) ⇒ Object

Sets the attribute config

Parameters:

  • value

    the value to set the attribute config to.

Raises:

  • (Applitools::EyesError)


73
74
75
# File 'lib/applitools/core/eyes_base.rb', line 73

def config=(value)
  @config = value
end

#cut_providerObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def cut_provider
  @cut_provider
end

#default_match_settingsObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def default_match_settings
  @default_match_settings
end

#exactObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def exact
  @exact
end

#failure_reportsObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def failure_reports
  @failure_reports
end

#inferred_environmentObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def inferred_environment
  @inferred_environment
end

#match_timeoutObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def match_timeout
  @match_timeout
end

#position_providerObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def position_provider
  @position_provider
end

#remove_session_if_matchingObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def remove_session_if_matching
  @remove_session_if_matching
end

#resultsObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def results
  @results
end

#runnerObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def runner
  @runner
end

#save_failed_testsObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def save_failed_tests
  @save_failed_tests
end

#save_new_testsObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def save_new_tests
  @save_new_tests
end

#scale_ratioObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def scale_ratio
  @scale_ratio
end

#screenshot_urlObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def screenshot_url
  @screenshot_url
end

#server_remainderObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def server_remainder
  @server_remainder
end

#server_scaleObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def server_scale
  @server_scale
end

#universal_driverObject

attr_accessor :universal_client, :universal_eyes_manager



106
107
108
# File 'lib/applitools/core/eyes_base.rb', line 106

def universal_driver
  @universal_driver
end

#universal_eyesObject

attr_accessor :universal_client, :universal_eyes_manager



106
107
108
# File 'lib/applitools/core/eyes_base.rb', line 106

def universal_eyes
  @universal_eyes
end

#verbose_resultsObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



# File 'lib/applitools/core/eyes_base.rb', line 80

#viewport_sizeObject

attr_accessor :agent_id, :session_type, :app_name, :test_name,



87
88
89
# File 'lib/applitools/core/eyes_base.rb', line 87

def viewport_size
  @viewport_size
end

Class Method Details

.environment_sdkObject



153
154
155
156
157
158
# File 'lib/applitools/core/eyes_base.rb', line 153

def self.environment_sdk
  {
    name: :eyes_core,
    currentVersion: Applitools::EyesCore::VERSION
  }
end

.get_execution_cloud_url(*args) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/applitools/core/eyes_base.rb', line 61

def get_execution_cloud_url(*args)
  options = Applitools::Utils.extract_options!(args)
  default_configs = Applitools::EyesBaseConfiguration::DEFAULT_CONFIG
  server_url = options[:server_url] || default_configs[:server_url]
  api_key = options[:api_key] || default_configs[:api_key]
  proxy = options[:proxy]
  @universal_client = Applitools::Connectivity::UniversalClient.new(self)
  core_ec_client = @universal_client.core_make_ec_client(server_url, api_key, proxy)
  core_ec_client[:url]
end

.set_viewport_size(driver, viewport_size) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/applitools/core/eyes_base.rb', line 44

def set_viewport_size(driver, viewport_size)
  Applitools::ArgumentGuard.not_nil(driver, 'Driver')
  Applitools::ArgumentGuard.not_nil(viewport_size, 'viewport_size')
  Applitools::ArgumentGuard.is_a?(viewport_size, 'viewport_size', Applitools::RectangleSize)
  Applitools::EyesLogger.info "Set viewport size #{viewport_size}"
  begin
    driver_config_json = driver.universal_driver_config
    required_size = Applitools::RectangleSize.from_any_argument viewport_size
    @universal_client = Applitools::Connectivity::UniversalClient.new(self)
    @universal_client.core_set_viewport_size(driver_config_json, required_size.to_hash)
  rescue => e
    Applitools::EyesLogger.error e.class
    Applitools::EyesLogger.error e.message
    raise Applitools::EyesError.new 'Failed to set viewport size!'
  end
end

Instance Method Details

#abort_if_not_closedObject Also known as: abort



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/applitools/core/eyes_base.rb', line 206

def abort_if_not_closed
  if disabled?
    logger.info "#{__method__} Ignored"
    return false
  end

  self.open = false
  self.last_screenshot = nil
  clear_user_inputs

  if !running_session && !universal_eyes
    logger.info('Server session was not started')
    logger.info('--- Empty test ended')
    return Applitools::TestResults.new
  end


  # if running_session.nil?
  #   logger.info 'Closed'
  #   return false
  # end

  logger.info 'Aborting server session...'
  universal_sdk_abort
rescue Applitools::EyesError => e
  logger.error e.message

ensure
  self.running_session = nil
end

#check_single_base(region_provider, retry_timeout, match_window_data) ⇒ Object



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/applitools/core/eyes_base.rb', line 356

def check_single_base(region_provider, retry_timeout, match_window_data)
  if disabled?
    logger.info "#{__method__} Ignored"
    result = Applitools::MatchResults.new
    result.as_expected = true
    return result
  end

  raise Applitools::EyesError.new 'Eyes not open' unless open?
  Applitools::ArgumentGuard.not_nil region_provider, 'region_provider'

  logger.info(
    "check_single_base(#{region_provider}, #{match_window_data.tag}, #{match_window_data.ignore_mismatch}," \
    " #{retry_timeout})"
  )

  tag = '' if tag.nil?

  self.session_start_info = SessionStartInfo.new agent_id: base_agent_id, app_id_or_name: app_name,
                                                 scenario_id_or_name: test_name, batch_info: batch,
                                                 baseline_env_name: baseline_env_name, environment: app_env,
                                                 default_match_settings: default_match_settings,
                                                 environment_name: environment_name, session_type: session_type,
                                                 branch_name: branch_name, parent_branch_name: parent_branch_name,
                                                 baseline_branch_name: baseline_branch_name, save_diffs: save_diffs,
                                                 properties: properties
  session_start_info.agent_run_id = agent_run_id if agent_run_id
  match_window_data.start_info = session_start_info
  match_window_data.update_baseline_if_new = save_new_tests
  match_window_data.update_baseline_if_different = save_failed_tests
  match_window_data.remove_session_if_matching = remove_session_if_matching
  match_window_data.scale = server_scale
  match_window_data.remainder = server_remainder

  match_window_task = Applitools::MatchSingleTask.new(
    logger,
    match_timeout,
    app_output_provider,
    server_connector
  )

  logger.info 'Calling match_window...'
  result = match_window_task.match_window(
    match_window_data,
    last_screenshot: last_screenshot,
    region_provider: region_provider,
    should_match_window_run_once_on_timeout: should_match_window_run_once_on_timeout,
    retry_timeout: retry_timeout
  ) do |match_results|
    results = match_results.original_results
    not_aborted = !results['isAborted']
    new_and_saved = results['isNew'] && save_new_tests
    different_and_saved = results['isDifferent'] && save_failed_tests
    not_a_mismatch = !results['isDifferent'] && !results['isNew']

    not_aborted && (new_and_saved || different_and_saved || not_a_mismatch)
  end
  logger.info 'match_window done!'

  if result.as_expected?
    clear_user_inputs
    self.last_screenshot = result.screenshot
  else
    unless match_window_data.ignore_mismatch
      clear_user_inputs
      self.last_screenshot = result.screenshot
    end

    self.should_match_window_run_once_on_timeout = true

    logger.info "Mistmatch! #{tag}"

    if failure_reports == :immediate
      raise Applitools::TestFailedException.new "Mistmatch found in #{session_start_info.scenario_id_or_name}" \
          " of #{session_start_info.app_id_or_name}"
    end
  end

  logger.info 'Done!'
  result.original_results
end

#check_window_base(region_provider, retry_timeout, match_window_data) ⇒ Object



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/applitools/core/eyes_base.rb', line 302

def check_window_base(region_provider, retry_timeout, match_window_data)
  if disabled?
    logger.info "#{__method__} Ignored"
    result = Applitools::MatchResults.new
    result.as_expected = true
    return result
  end

  raise Applitools::EyesError.new 'Eyes not open' unless open?
  Applitools::ArgumentGuard.not_nil region_provider, 'region_provider'

  logger.info(
    "check_window_base(#{region_provider}, #{match_window_data.tag}, #{match_window_data.ignore_mismatch}," \
    " #{retry_timeout})"
  )

  tag = '' if tag.nil?

  ensure_running_session

  match_window_data.user_inputs = user_inputs

  logger.info 'Calling match_window...'
  result = @match_window_task.match_window(
    match_window_data,
    last_screenshot: last_screenshot,
    region_provider: region_provider,
    should_match_window_run_once_on_timeout: should_match_window_run_once_on_timeout,
    retry_timeout: retry_timeout
  )
  logger.info 'match_window done!'

  if result.as_expected?
    clear_user_inputs
    self.last_screenshot = result.screenshot
  else
    unless match_window_data.ignore_mismatch
      clear_user_inputs
      self.last_screenshot = result.screenshot
    end

    self.failed = true
    logger.info "Mistmatch! #{tag}" unless running_session.new_session?

    if failure_reports == :immediate
      raise Applitools::TestFailedException.new "Mistmatch found in #{session_start_info.scenario_id_or_name}" \
          " of #{session_start_info.app_id_or_name}"
    end
  end

  logger.info 'Done!'
  result
end

#close(throw_exception = true, be_silent = false) ⇒ Object

Closes eyes otherwise the test will pass. Default is true

Parameters:

  • throw_exception (Boolean) (defaults to: true)

    If set to true eyes will trow [Applitools::TestFailedError] exception,



442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/applitools/core/eyes_base.rb', line 442

def close(throw_exception = true, be_silent = false)
  if disabled?
    logger.info "#{__method__} Ignored"
    return false
  end

  logger.info "close(#{throw_exception})"
  raise Applitools::EyesError.new 'Eyes not open' unless open?

  if !running_session && !universal_eyes
    be_silent || logger.info('Server session was not started')
    be_silent || logger.info('--- Empty test ended')
    return Applitools::TestResults.new
  end

  # is_new_session = running_session.new_session?
  # session_results_url = running_session.url

  logger.info 'Ending server session...'

  # save = is_new_session && save_new_tests || !is_new_session && failed && save_failed_tests

  # logger.info "Automatically save test? #{save}"

  # U-Notes : universal server returns Array ; keys as sym
  universal_eyes.close # nil
  results = get_results(throw_exception)
#   universal_results = universal_eyes.eyes_get_results # Array even for one test
#   # require 'pry'
#   # binding.pry
#   # error from universal server
#   if universal_results.is_a?(Hash) && universal_results[:message] && universal_results[:stack] && universal_results[:reason]
#     logger.error "--- Error (#{universal_results[:reason]}) : #{universal_results[:message]}"
#     error_message = "Test '#{test_name}' of '#{app_name}' " \
#       "is failed! Details : #{universal_results[:message]}"
#     raise Applitools::TestFailedError.new error_message, results if throw_exception
#     return universal_results
#   end
#   key_transformed_results = Applitools::Utils.deep_stringify_keys(universal_results)
#   results = key_transformed_results.map {|result| Applitools::TestResults.new(result) }
#   results = results.first if results.size >= 1
#
#   session_results_url = results.url
#   # results = server_connector.stop_session running_session, false, save
#   runner.aggregate_result(results) if runner
#
#   # results.is_new = is_new_session
#   # results.url = session_results_url
#   save = results.new? && save_new_tests || !results.new? && failed && save_failed_tests
#   logger.info "Automatically save test? #{save}"
#
#   logger.info results.to_s(verbose_results)
#
#   if results.unresolved?
#     if results.new?
#       logger.error "--- New test ended. see details at #{session_results_url}"
#       error_message = "New test '#{test_name}' " \
#         "of '#{app_name}' " \
#         "Please approve the baseline at #{session_results_url} "
#       raise Applitools::NewTestError.new error_message, results if throw_exception
#     else
#       logger.error "--- Differences are found. see details at #{session_results_url}"
#       error_message = "Test '#{test_name}' " \
#         "of '#{app_name}' " \
#         "detected differences! See details at #{session_results_url}"
#       raise Applitools::DiffsFoundError.new error_message, results if throw_exception
#     end
#     return results
#   end
#
#   if results.failed?
#     logger.error "--- Failed test ended. see details at #{session_results_url}"
#     error_message = "Test '#{test_name}' of '#{app_name}' " \
#         "is failed! See details at #{session_results_url}"
#     raise Applitools::TestFailedError.new error_message, results if throw_exception
#     return results
#   end

  logger.info '--- Test passed'
  self.results.push results

  # match old style one result
  if results.is_a?(Array) && results.first.is_a?(Applitools::TestResults)
    return results.first if results.size >= 1
  end
  return results
ensure
  self.running_session = nil
  self.app_name = ''
end

#configurationObject Also known as: get_configuration



609
610
611
# File 'lib/applitools/core/eyes_base.rb', line 609

def configuration
  config.deep_dup
end

#configuration=(value) ⇒ Object Also known as: set_configuration



615
616
617
618
# File 'lib/applitools/core/eyes_base.rb', line 615

def configuration=(value)
  Applitools::ArgumentGuard.is_a?(value, :configuration, Applitools::EyesBaseConfiguration)
  self.config = value.deep_dup
end

#disabled=(value) ⇒ Object



186
187
188
# File 'lib/applitools/core/eyes_base.rb', line 186

def disabled=(value)
  @disabled = Applitools::Utils.boolean_value value
end

#disabled?Boolean

Returns:

  • (Boolean)


190
191
192
# File 'lib/applitools/core/eyes_base.rb', line 190

def disabled?
  @disabled
end

#ensure_configObject



160
161
162
# File 'lib/applitools/core/eyes_base.rb', line 160

def ensure_config
  self.config = Applitools::EyesBaseConfiguration.new
end

#ensure_running_sessionObject



287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/applitools/core/eyes_base.rb', line 287

def ensure_running_session
  return if running_session

  logger.info 'No running session, calling start session..'
  start_session
  logger.info 'Done!'
  @match_window_task = Applitools::MatchWindowTask.new(
    logger,
    running_session,
    match_timeout,
    app_output_provider,
    server_connector
  )
end

#get_results(throw_exception = true) ⇒ Object



533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# File 'lib/applitools/core/eyes_base.rb', line 533

def get_results(throw_exception = true)
  if disabled?
    logger.info "#{__method__} Ignored"
    return false
  end

  self.open = false
  self.last_screenshot = nil
  clear_user_inputs

  logger.info 'Getting results...'

  universal_results = universal_eyes.eyes_get_results # Array even for one test
  # require 'pry'
  # binding.pry
  # error from universal server
  if universal_results.is_a?(Hash) && universal_results[:message] && universal_results[:stack] && universal_results[:reason]
    logger.error "--- Error (#{universal_results[:reason]}) : #{universal_results[:message]}"
    error_message = "Test '#{test_name}' of '#{app_name}' " \
      "is failed! Details : #{universal_results[:message]}"
    raise Applitools::TestFailedError.new error_message, results if throw_exception
    return universal_results
  end
  key_transformed_results = Applitools::Utils.deep_stringify_keys(universal_results)
  results = key_transformed_results.map {|result| Applitools::TestResults.new(result) }
  # results = results.first if results.size >= 1

  session_results_url = results.first.url
  # results = server_connector.stop_session running_session, false, save

  results.each { |result| runner.aggregate_result(result) } if runner

  # results.is_new = is_new_session
  # results.url = session_results_url
  save = (results.any?(&:new?) && save_new_tests) || (!results.any?(&:new?) && failed && save_failed_tests)
  logger.info "Automatically save test? #{save}"

  logger.info results.first.to_s(verbose_results)

  if results.any?(&:unresolved?)
    if results.any?(&:new?)
      logger.error "--- New test ended. see details at #{session_results_url}"
      error_message = "New test '#{test_name}' " \
        "of '#{app_name}' " \
        "Please approve the baseline at #{session_results_url} "
      raise Applitools::NewTestError.new error_message, results if throw_exception
    else
      logger.error "--- Differences are found. see details at #{session_results_url}"
      error_message = "Test '#{test_name}' " \
        "of '#{app_name}' " \
        "detected differences! See details at #{session_results_url}"
      raise Applitools::DiffsFoundError.new error_message, results if throw_exception
    end
    return results
  end

  if results.any?(&:failed?)
    logger.error "--- Failed test ended. see details at #{session_results_url}"
    error_message = "Test '#{test_name}' of '#{app_name}' " \
      "is failed! See details at #{session_results_url}"
    raise Applitools::TestFailedError.new error_message, results if throw_exception
    return results
  end

  # logger.info '--- Test passed'
  # self.results.push results
  return results
ensure
  self.running_session = nil
  self.app_name = ''
end

#merge_config(other_config) ⇒ Object

def update_config_from_options(options)

# Applitools::ArgumentGuard.hash options, 'open_base parameter', [:test_name]
default_options = { session_type: 'SEQUENTIAL' }
options = default_options.merge options

self.app_name = options[:app_name] if options[:app_name]

# Applitools::ArgumentGuard.not_nil options[:test_name], 'options[:test_name]'
self.test_name = options[:test_name] if options[:test_name]
self.viewport_size = options[:viewport_size] if options[:viewport_size]
self.session_type = options[:session_type] if options[:session_type]

end



283
284
285
# File 'lib/applitools/core/eyes_base.rb', line 283

def merge_config(other_config)
  config.merge(other_config)
end

#new_session?Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/applitools/core/eyes_base.rb', line 202

def new_session?
  running_session && running_session.new_session?
end

#open?Boolean

Returns:

  • (Boolean)


194
195
196
# File 'lib/applitools/core/eyes_base.rb', line 194

def open?
  @open
end

#open_base(options = {}) ⇒ Object



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/applitools/core/eyes_base.rb', line 239

def open_base(options = {})
  self.results = []
  if disabled?
    logger.info "#{__method__} Ignored"
    return false
  end

  if open?
    abort_if_not_closed
    raise Applitools::EyesError.new 'A test is already running'
  end

  update_config_from_options(options)

  raise Applitools::EyesIllegalArgument, config.validation_errors.values.join('/n') unless config.valid?

  logger.info "Agent = #{full_agent_id}"
  logger.info "openBase(app_name: #{app_name}, test_name: #{test_name}," \
      " viewport_size: #{viewport_size})"

  raise Applitools::EyesError.new 'API key is missing! Please set it using api_key=' if
    api_key.nil? || (api_key && api_key.empty?)

  yield if block_given?

  self.open = true
rescue Applitools::EyesError => e
  logger.error e.message
  raise e
end

#running_session?Boolean

Returns:

  • (Boolean)


198
199
200
# File 'lib/applitools/core/eyes_base.rb', line 198

def running_session?
  running_session.nil? ? false : true
end

#server_connectorObject



171
172
173
174
175
176
# File 'lib/applitools/core/eyes_base.rb', line 171

def server_connector
  @server_connector.server_url = config.server_url
  @server_connector.api_key = config.api_key
  @server_connector.proxy = config.proxy if config.proxy
  @server_connector
end