from __future__ import print_function

import os
from contextlib import contextmanager

from selenium import webdriver

from aloe import around, world

here = os.path.dirname(__file__)
html_pages = os.path.join(here, 'html_pages')


@around.each_feature
@contextmanager
def with_browser(feature):
    world.browser = webdriver.Firefox()
    world.browser.get('')
    yield
    world.browser.quit()
    delattr(world, 'browser')


@around.each_step
@contextmanager
def print_source(step):
    try:
        yield
    except:
        print(world.browser.page_source)
        print(world.browser.get_screenshot_as_base64())
        raise

@@ -516,16 +516,256 @@
 except:%0A
+        try:%0A            step_container = step.scenario%0A        except AttributeError:%0A            step_container = step.background%0A%0A        print(step_container.feature.name)%0A        print(step_container.name)%0A        print(step.sentence)%0A
         

Print scenario/step names on failure