Issue
I try to get the current UI-Layout as xml. I already found out that there is a tool called "UI Automator" and there is also an adb command to get the layout as XML adb shell uiautomator dump
.
There are two problems with the command and tool. Firstly, it can't pick up a layout when the structure changes very quickly (an error message appears ERROR: null root node returned by UiTestAutomationBridge.
) and secondly, there is also a bug where sometimes an error occurs when querying the layout. And it is terribly slow (about 2s).
Now I found a newer tool in Android Studio called "Layout Inspector" (under the tools section) that don't have these issues (instant xml response, no problem with fast layouts and no random errors). The problem is that I can't find any adb command (the tool only works when a device is available over adb) to get the xml structure manually. I also found out that there are some apps that behave same (e.g. Developer Assistant).
So how can I get the current Layout without UiAutomator over adb?
Solution
CulebraTester2-public which is a pluggable AndroidViewClient back-end, can also be used in stand-alone mode in 3 simple steps.
- Install CulebraTester2-public APKs (prebuilt APKs can be found here)
- Start the service
./culebratester2 start-server
- Execute dump-window-hierarcy
This won't have, in general, a problem downloading the hierarchy when the windows are being updated and it will be much faster than uiautomator dump
.
The previous example is using curl
to make the request to the service but you can also use culebratester_client from python.
Additionally, you can use dump
from AndroidViewClient
specifying the CulebraTester2 back-end (a.k.a. uiautomator-helper)
$ dump --use-uiautomator-helper --all
Answered By - Diego Torres Milano
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.