Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in using UIAutomatorviewer for testing Android app in Appium

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. 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:

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?
like image 224
Rancho Avatar asked Aug 08 '14 10:08

Rancho


People also ask

What is Uiautomatorviewer in Appium?

What is UiAutomatorViewer? “UIautomatorviewer” is a GUI tool to scan and analyze the UI components of an Android application.To automate any android application using Appium, a user needs to identify the objects in AUT (Application under test).

How do I run Uiautomatorviewer?

Open command prompt anywhere and enter command uiautomatorviewer. Note that there are no spaces in the command and it is just a single word. If you have configured the SDK properly, then you will get a UIAutomator window opened. Otherwise please check if the installation and configuration are done properly.


2 Answers

After my tryst with the uiautomator viewer i came to know that we get the error only when:

appium server is running and we try to capture the screenshot using uiautomatorviewer.

So, whenever you want to use uiautomatorviewer make sure that server is in stopped state.

like image 158
Rancho Avatar answered Sep 21 '22 16:09

Rancho


I fixed the same issue by using following methods.

(1) Connect your Android device to your development machines;

(2) Go to command line in terminal or DOS command line for Windows;

(3) Using "adb shell" into your Android devices;

(4) Change the user to root by input "su root" in command line;

(5) Change the access right to /data/local/tmp by input "chmod 777 /data/local/tmp";

(6) Go back to uiautomatorviewer and do screen shot again, the error should be gone;

I guess there are some file can't be access if it doesn't own right in /data/local/tmp.

like image 39
Damon Song Avatar answered Sep 21 '22 16:09

Damon Song