Sha256: 9410eb055450a9b68b4f78c11949b68df07a3e4ec29f1a8a940c663b56ff25f0

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EhbrsRubyUtils
  module Bga
    class Session < ::SimpleDelegator
      module SkipTrophies
        TROPHY_SKIP_BUTTON_XPATH = '//*[@id = "splashedNotifications_overlay"]' \
          '//*[starts-with(@id, "continue_btn_")]'
        TROPHY_SKIP_TIMEOUT = 5

        # @param &block [Proc]
        # @return [Selenium::WebDriver::Error::TimeoutError, nil]
        def on_rescue_timeout(&block)
          block.call
          nil
        rescue ::Selenium::WebDriver::Error::TimeoutError => e
          e
        end

        def on_skip_trophies(&block)
          error = on_rescue_timeout(&block)
          return unless error
          raise error unless skip_trophy_overlay?

          skip_trophies
        end

        def skip_trophies
          loop do
            wait_for_click({ xpath: TROPHY_SKIP_BUTTON_XPATH }, TROPHY_SKIP_TIMEOUT)
          rescue ::Selenium::WebDriver::Error::TimeoutError
            break
          end
        end

        # @return [Boolean]
        def skip_trophy_overlay?
          find_or_not_element(xpath: TROPHY_SKIP_BUTTON_XPATH).present?
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ehbrs_ruby_utils-0.33.0 lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb
ehbrs_ruby_utils-0.32.0 lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb
ehbrs_ruby_utils-0.31.0 lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb
ehbrs_ruby_utils-0.30.0 lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb
ehbrs_ruby_utils-0.29.0 lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb
ehbrs_ruby_utils-0.28.0 lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb
ehbrs_ruby_utils-0.27.1 lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb
ehbrs_ruby_utils-0.27.0 lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb