Module: Howitzer::Web::CapybaraMethodsProxy

Included in:
BaseSection, Page
Defined in:
lib/howitzer/web/capybara_methods_proxy.rb

Overview

This module proxies required original capybara methods to recipient

Constant Summary collapse

PROXIED_CAPYBARA_METHODS =

:nodoc:

Capybara::Session::SESSION_METHODS + # :nodoc:
Capybara::Session::MODAL_METHODS +
%i[driver text]

Instance Method Summary collapse

Instance Method Details

#click_alert_box(flag) ⇒ Object

Accepts or declines JS alert box by given flag

Parameters:

  • flag (Boolean)

    Determines accept or decline alert box



56
57
58
59
60
61
62
63
# File 'lib/howitzer/web/capybara_methods_proxy.rb', line 56

def click_alert_box(flag)
  if %w[selenium sauce].include? Howitzer.driver
    alert = driver.browser.switch_to.alert
    flag ? alert.accept : alert.dismiss
  else
    evaluate_script("window.confirm = function() { return #{flag}; }")
  end
end