Module: EhbrsRubyUtils::Bga::Session::SkipTrophies

Defined in:
lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb

Constant Summary collapse

TROPHY_SKIP_BUTTON_XPATH =
'//*[@id = "splashedNotifications_overlay"]' \
'//*[starts-with(@id, "continue_btn_")]'
TROPHY_SKIP_TIMEOUT =
5

Instance Method Summary collapse

Instance Method Details

#on_rescue_timeout(&block) ⇒ Selenium::WebDriver::Error::TimeoutError?

Parameters:

  • &block (Proc)

Returns:

  • (Selenium::WebDriver::Error::TimeoutError, nil)


15
16
17
18
19
20
# File 'lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb', line 15

def on_rescue_timeout(&block)
  block.call
  nil
rescue ::Selenium::WebDriver::Error::TimeoutError => e
  e
end

#on_skip_trophies(&block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb', line 22

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

  skip_trophies
end

#skip_trophiesObject



30
31
32
33
34
35
36
# File 'lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb', line 30

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

#skip_trophy_overlay?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ehbrs_ruby_utils/bga/session/skip_trophies.rb', line 39

def skip_trophy_overlay?
  find_or_not_element(xpath: TROPHY_SKIP_BUTTON_XPATH).present?
end