1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-07-05 14:43:41 +01:00

Dump hierarchy view on error

Dump window hierarchy view from uiautomator to a file when WA fails
during execution. Note: the xml file are pre-formatted after dump.
Implementation specific to android.device.
This commit is contained in:
John Richardson
2016-08-02 16:21:47 +01:00
parent 4c94ba43ac
commit 0945dd6ba4
2 changed files with 21 additions and 0 deletions
wlauto
common
android
core

@ -731,6 +731,13 @@ class Runner(object):
filepath = os.path.join(settings.output_directory, filename)
self.device.capture_screen(filepath)
def _take_uiautomator_dump(self, filename):
if self.context.output_directory:
filepath = os.path.join(self.context.output_directory, filename)
else:
filepath = os.path.join(settings.output_directory, filename)
self.device.capture_view_hierachy(filepath)
@contextmanager
def _handle_errors(self, action, on_error_status=IterationResult.FAILED):
try:
@ -746,6 +753,8 @@ class Runner(object):
self.current_job.result.add_event(str(we))
try:
self._take_screenshot('error.png')
if self.device.platform == 'android':
self._take_uiautomator_dump('error.xml')
except Exception, e: # pylint: disable=W0703
# We're already in error state, so the fact that taking a
# screenshot failed is not surprising...