require 'singleton' require 'eyes_selenium' module Scoutui::Eyes class EyeFactory include Singleton attr_accessor :eyesList def initialize @eyesList=Array.new() end def createScout() browserType = Scoutui::Base::UserVars.instance.getBrowserType() puts __FILE__ + (__LINE__).to_s + "BrowserType : #{browserType}" eyeScout = EyeScout.new(browserType) end def createEyes() use_eyes = Scoutui::Utils::TestUtils.instance.eyesEnabled? Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " create(#{use_eyes})" if Scoutui::Utils::TestUtils.instance.isDebug? eyes=nil if use_eyes license_key=nil licFile=Scoutui::Utils::TestUtils.instance.getLicenseFile() if !licFile.empty? valid_json=false begin jFile = File.read(licFile) jLicense=jsonData=JSON.parse(jFile) license_key=jLicense['api_key'].to_s valid_json=true rescue => ex ; end elsif ENV.has_key?('APPLITOOLS_API_KEY') Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " APPLITOOLS_API_KEY from ENV" license_key=ENV['APPLITOOLS_API_KEY'].to_s end if !license_key.nil? eyes=Applitools::Eyes.new() Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Eyes Object created #{eyes}" eyes.api_key = license_key eyes.force_fullpage_screenshot = Scoutui::Utils::TestUtils.instance.eyesFullscreen? #true match_level = Scoutui::Base::UserVars.instance.getVar('eyes.match_level') eyes.match_level = Applitools::Eyes::MATCH_LEVEL[match_level.to_sym] if !Scoutui::Utils::TestUtils.instance.eyesBatchname().nil? batch = Applitools::Base::BatchInfo.new(Scoutui::Utils::TestUtils.instance.eyesBatchname()) if !Scoutui::Utils::TestUtils.instance.eyesBatchId().nil? batch.id = Scoutui::Utils::TestUtils.instance.eyesBatchId() end eyes.batch = batch end Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " eyes => #{eyes}" end ## TBD - eyes.open() end # eyes @eyesList << eyes @eyesList.last() end end end