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 +
[: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



21
22
23
24
25
26
27
28
# File 'lib/howitzer/web/capybara_methods_proxy.rb', line 21

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