Şu anda uiautomator böyle UI dökümü yapmak kullanıyorum. Bu yüzden bunu yapmanın daha hızlı bir yolu var mı acaba? Kullanıcı arayüzünü terk eden bir servis oluşturmak gibi mi, yoksa bu kadar uzun sürecek mi?Kullanıcı Arabirimi hiyerarşisini dökmenin daha hızlı bir yolu var mı?</p> <pre><code>adb shell uiautomator dump </code></pre> <p>Ve bunu gerçekleştirmek için yaklaşık 3 saniye sürer dışında çalışıyor:
6
A
cevap
7
Bunu yapmanın daha iyi bir yolunu bulduğum gibi kendi sorumu yanıtlamam gerekir.
https://github.com/xiaocong/android-uiautomator-server#build
Bu neredeyse anında damping yapmak ve gerçekten güzel çalışır: cihaza komutlar göndermek yüzden hafif rpc sunucusu ile togheter uiautomator kullanmak bu projeyi gördük. Eğer rpc arama yapmak için nasıl görmek istiyorsanız O da bir piton projesi var:
https://github.com/xiaocong/uiautomator
Ama burada küçük bir örnek oluşturduk.
Başlangıç sunucusu:
# Start the process
process = subprocess.Popen(
'adb shell uiautomator runtest '
'bundle.jar uiautomator-stub.jar '
'-c com.github.uiautomatorstub.Stub', stdout=subprocess.PIPE, shell=True)
# Forward adb ports
subprocess.call('adb forward tcp:9008 tcp:9009')
Fonksiyon ("dumpWindowHierarchy" vb "ping") komutlarını çağırmayı: Dosyaları itmek zorunda
def send_command(self, method_name, *args):
"""
Send command to the RPC server
Args:
method_name(string): Name of method to run
*args: Arguments
"""
data = {
'jsonrpc': '2.0',
'method': method_name,
'id': 1,
}
if args:
data['params'] = args
request = urllib2.Request(
'http://localhost:{0}/jsonrpc/0'.format(self.local_port),
json.dumps(data),
{
'Content-type': 'application/json'
})
try:
result = urllib2.urlopen(request, timeout=30)
except Exception as e:
return None
if result is None:
return None
json_result = json.loads(result.read())
if 'error' in json_result:
raise JsonRPCError('1',
'Exception when sending command to '
'UIAutomatorServer: {0}'.format(
json_result['error']))
return json_result['result']
Not (bundle.jar anduiautomator -stub.jar) ilk projeden önce cihaza ve "/ data/local/tmp /" dizinine koyun.