Sha256: 45aac0bfe203d32ec6066a438e1433f8fa24928c03d59f563bd9949670188892

Contents?: true

Size: 957 Bytes

Versions: 3

Compression:

Stored size: 957 Bytes

Contents

Before do |feature|
  ## variable which loads the data file according to the environment
  CONFIG = YAML.load_file(File.dirname(__FILE__) + "/config/#{ENVIRONMENT_TYPE}.yaml")

  ## configure the chosen browser
  Capybara.configure do |config|
    config.default_driver = :selenium
  end

  ## set default max wait and maximize browser
  Capybara.default_max_wait_time = 20
  Capybara.current_session.driver.browser.manage.window.maximize
end

After do |scenario|

  ## take screenshot if scenario fail
  if scenario.failed?
    folder = 'screenshots'
    file = "#{folder}/#{scenario.name}.png"
    Dir.mkdir(folder) unless File.exist?(folder)
    if BROWSER.eql?('poltergeist')
      Capybara.page.save_screenshot(file)
    else
      Capybara.page.driver.browser.save_screenshot(file)
    end
  end

  ## if the browser is different from poltergeist, kills instance
  unless BROWSER.eql?('poltergeist')
    Capybara.current_session.driver.quit
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cs-webautomator-0.1.8 lib/skeleton/features/support/hooks.rb
cs-webautomator-0.1.7 lib/skeleton/features/support/hooks.rb
cs-webautomator-0.1.6 lib/skeleton/features/support/hooks.rb