From 30f856abe03cc122ece6b033cced878b98035197 Mon Sep 17 00:00:00 2001
From: Marc Bonnici <marc.bonnici@arm.com>
Date: Wed, 23 May 2018 14:56:35 +0100
Subject: [PATCH] framework/execution: Only add screenshots as an artifact if
 present

When attempting to take a screenshot from a device do not try to add it
as an artifact if screenshot failed and is not present.
---
 wa/framework/execution.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/wa/framework/execution.py b/wa/framework/execution.py
index 96c8b3cb..22e05fa7 100644
--- a/wa/framework/execution.py
+++ b/wa/framework/execution.py
@@ -227,7 +227,8 @@ class ExecutionContext(object):
     def take_screenshot(self, filename):
         filepath = self._get_unique_filepath(filename)
         self.tm.target.capture_screen(filepath)
-        self.add_artifact('screenshot', filepath, kind='log')
+        if os.path.isfile(filepath):
+            self.add_artifact('screenshot', filepath, kind='log')
 
     def take_uiautomator_dump(self, filename):
         filepath = self._get_unique_filepath(filename)