Error in using UIAutomatorviewer for testing Andro

2019-01-18 03:45发布

I have to automate an Android application, I am doing the same through Appium. The problem I am facing is after launching the Appium server, the app is getting installed in the emulator 4.4.2 and to inspect the element I am using UIAutomatorviewer which comes default with SDK. But while inspecting the element of the app, I am getting the error![enter image description here][1]

Error obtaining UI hierarchy
Reason:Error while obtaining UI hierarchy XML file.com.android.ddmlb.SynchException.Remote object doesn't exist.

I tried to find the solution so that I can inspect the element so that I can script, but in vain.

  1. Can someone please tell how to fix the issue so that I can inspect elements?
  2. Is there any other way I can inspect element in the app apart from using UIAutomator viewer?

19条回答
够拽才男人
2楼-- · 2019-01-18 04:20

I had the same problem because I used "adbd insecure". So I just disabled "adbd insecure", and reload uiautomatorviewer, everything is OK.

查看更多
迷人小祖宗
3楼-- · 2019-01-18 04:20

This happens because adb is using port and it's blocked by appium server.

I have found out best solution for this

Kill the adb.exe from taskbar processes and try launching uiautomatorviewer again

查看更多
乱世女痞
4楼-- · 2019-01-18 04:20

try switching Off and then ON the USB debugging option.. this work for me

查看更多
Melony?
5楼-- · 2019-01-18 04:22

In case of rooted devices: Enable the root access in developer options for adb. Restart adb as root

查看更多
一夜七次
6楼-- · 2019-01-18 04:22

What worked for me:

stop appium
open an emulator device (tested with Android 7.1.1)
go into settings > developer options > Enable view attribute inspection
open a shell on the computer, cmd or terminal depending on your OS
enter the following commands:
adb shell
su
cd /data
cd /local
chmod 777 tmp

start uiautomatorviewer
take an xml screenshot

"su chmod 777 /data/local/tmp" didnt work for me so I drilled down and it worked.
I assume that you have to do this in an emulator and not a physical device unless the device is rooted. ¯ \ _ (ツ)_/¯

Lotsa Luck!

查看更多
对你真心纯属浪费
7楼-- · 2019-01-18 04:24

we have to use device which has API level morethan 17 or jelly bean

查看更多
登录 后发表回答