1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-02-07 05:30:44 +00:00

AndroidTarget: add capture_ui_hierarchy

Add a method to dump XML UI hierarchy from uiautomator.
This commit is contained in:
Sergei Trofimov 2018-03-21 14:57:05 +00:00 committed by Marc Bonnici
parent 078f0dc641
commit 9678c7372e

View File

@ -7,6 +7,7 @@ import subprocess
import tarfile
import tempfile
import threading
import xml.dom.minidom
from collections import namedtuple
from devlib.host import LocalConnection, PACKAGE_BIN_DIRECTORY
@ -1175,6 +1176,16 @@ class AndroidTarget(Target):
return props[prop]
return props
def capture_ui_hierarchy(self, filepath):
on_target_file = self.get_workpath('screen_capture.xml')
self.execute('uiautomator dump {}'.format(on_target_file))
self.pull(on_target_file, filepath)
self.remove(on_target_file)
parsed_xml = xml.dom.minidom.parse(filepath)
with open(filepath, 'w') as f:
f.write(parsed_xml.toprettyxml())
def is_installed(self, name):
return super(AndroidTarget, self).is_installed(name) or self.package_is_installed(name)