mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-14 17:07:50 +00:00
AndroidTarget: add capture_ui_hierarchy
Add a method to dump XML UI hierarchy from uiautomator.
This commit is contained in:
parent
078f0dc641
commit
9678c7372e
@ -7,6 +7,7 @@ import subprocess
|
|||||||
import tarfile
|
import tarfile
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
|
import xml.dom.minidom
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from devlib.host import LocalConnection, PACKAGE_BIN_DIRECTORY
|
from devlib.host import LocalConnection, PACKAGE_BIN_DIRECTORY
|
||||||
@ -1175,6 +1176,16 @@ class AndroidTarget(Target):
|
|||||||
return props[prop]
|
return props[prop]
|
||||||
return props
|
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):
|
def is_installed(self, name):
|
||||||
return super(AndroidTarget, self).is_installed(name) or self.package_is_installed(name)
|
return super(AndroidTarget, self).is_installed(name) or self.package_is_installed(name)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user