Commit 17cd7112 authored by Vadim Rutkovsky's avatar Vadim Rutkovsky

tests: store the screenshot for failed tests

parent 4ed443d4
...@@ -7,6 +7,7 @@ if not isA11yEnabled(): ...@@ -7,6 +7,7 @@ if not isA11yEnabled():
from common_steps import App, dummy, cleanup from common_steps import App, dummy, cleanup
from dogtail.config import config from dogtail.config import config
import os
def before_all(context): def before_all(context):
...@@ -31,6 +32,20 @@ def before_all(context): ...@@ -31,6 +32,20 @@ def before_all(context):
print("Error in before_all: %s" % e.message) print("Error in before_all: %s" % e.message)
def after_step(context, step):
try:
if step.status == 'failed' and hasattr(context, "embed"):
# Embed screenshot if HTML report is used
os.system("dbus-send --print-reply --session --type=method_call " +
"--dest='org.gnome.Shell.Screenshot' " +
"'/org/gnome/Shell/Screenshot' " +
"org.gnome.Shell.Screenshot.Screenshot " +
"boolean:true boolean:false string:/tmp/screenshot.png")
context.embed('image/png', open("/tmp/screenshot.png", 'r').read())
except Exception as e:
print("Error in after_step: %s" % str(e))
def after_scenario(context, scenario): def after_scenario(context, scenario):
"""Teardown for each scenario """Teardown for each scenario
Kill evolution (in order to make this reliable we send sigkill) Kill evolution (in order to make this reliable we send sigkill)
......
...@@ -119,4 +119,4 @@ def task_editor_with_title_is_opened(context, title): ...@@ -119,4 +119,4 @@ def task_editor_with_title_is_opened(context, title):
@step(u'Event editor with title "{name}" is displayed') @step(u'Event editor with title "{name}" is displayed')
def event_editor_with_name_displayed(context, name): def event_editor_with_name_displayed(context, name):
context.app.event_editor = context.app.window(name) context.app.event_editor = context.app.window(name)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment