Getting UIX file suitable for uiautomatorviewer

My test automation saves screenshots as it runs for debugging purposes. I wanted also to save uix files so I could come back with uiautomatorviewer and load the structure to go with the screenshot. Unfortunately there didn’t seem to be a good way to save them without hacking into appium’s androidbootstrap jar. Doing an ‘adb uiatomator dump’ didn’t work as appium has a running uiautomator process and android doesn’t seem to permit two to be running concurrently.

In my efforts, I discovered that when appium generates pageSource, in the format that we all know and hate, it uses a tempfile in the uix format. It is merely a matter of grabbing that uix tempfile after doing a getPageSource!

An adb pull will get it for you:
adb pull /data/local/tmp/local/tmp/dump.xml savefile.uix

We do something similar, @adamf663. I’m comfortable enough working directly with the xml that I don’t need to pull it up in uiautomatorviewer to find what I’m looking for, so we just call get_source and pipe the output through some nokogiri magic and save it to a file. This has proved very useful when debugging failures.

1 Like

Does this still work in 2020?

I’m new to appium. When I run this adb pull. I get error:
“output: adb: error: remote object ‘/data/local/tmp/local/tmp/dump.xml’ does not exist”

And I’m also running driver.getPageSource(); before it.