1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-03 20:02:39 +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

View File

@@ -22,6 +22,7 @@ import tempfile
import shutil
import threading
import json
import xml.dom.minidom
from subprocess import CalledProcessError
from wlauto.core.extension import Parameter
@@ -616,6 +617,17 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
self.pull_file(on_device_file, filepath)
self.delete_file(on_device_file)
def capture_view_hierachy(self, filepath):
"""Captures the current view hierarchy into the specified file in a XML format."""
on_device_file = self.path.join(self.working_directory, 'screen_capture.xml')
self.execute('uiautomator dump {}'.format(on_device_file))
self.pull_file(on_device_file, filepath)
self.delete_file(on_device_file)
parsed_xml = xml.dom.minidom.parse(filepath)
with open(filepath, 'w') as f:
f.write(parsed_xml.toprettyxml())
def is_screen_on(self):
"""Returns ``True`` if the device screen is currently on, ``False`` otherwise."""
output = self.execute('dumpsys power')