Questions tagged [android-uiautomator]

The uiautomator testing framework lets you test your user interface (UI) efficiently by creating automated functional UI testcases that can be run against your app on one or more devices.

The UI Automator testing framework is included in the Android SDK. UI Automator lets you test the user interface (UI) of Android apps efficiently by creating automated functional UI test cases that can be run against your app on one or more devices. Because it interacts with GUI elements of Android apps it can be used to test most apps, including pre-installed system apps such as Settings; and third-party apps.

In addition to unit testing the individual components that make up your Android application (such as activities, services, and content providers), it is also important that you test the behavior of your application’s user interface (UI) when it is running on a device. UI testing ensures that your application returns the correct UI output in response to a sequence of user actions on a device, such as entering keyboard input or pressing toolbars, menus, dialogs, images, and other UI controls.

Useful links

905 questions
158
votes
19 answers

Cannot resolve symbol 'AndroidJUnit4'

Obviously I need the correct import statment to solve this problem. According to the docs for AndroidJUnit4, this should be import android.support.test.runner.AndroidJUnit4; When I do that, Android Studio highlights runner in red and complains…
81
votes
7 answers

Android Testing: UIAutomator vs Espresso

I was seeking for test frameworks for Android UI automation and I stumbled upon UI Automator and Espresso and this is the part I am confused about - Both are maintained by Google Both are used for functional UI testing Both are Android only…
Shikhar
  • 1,411
  • 1
  • 11
  • 17
52
votes
11 answers

Set different minSdkVersion for testAndroid than for main app

Is it possible to set a different minSdkVersion for tests than for the app itself? I ask because I want to use the new Test Support Library and UI Automator for testing. However, this is only available on API 18+. At the same time, I still want to…
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
44
votes
8 answers

Is there a way to get current activity's layout and views via adb?

For environment reasons I can only use adb commands. Is there a way to get the current layout attributes like id, position, text etc ? Similar to what uiautomatorviewer shows.
Filipe Arruda
  • 628
  • 1
  • 5
  • 13
36
votes
8 answers

Android testing: Waited for the root of the view hierarchy to have window focus

In Android Ui testing, I want to click on a spinner item in a dialog, but it pop up with this error: va.lang.RuntimeException: Waited for the root of the view hierarchy to have window focus and not be requesting layout for over 10 seconds. If you…
28
votes
14 answers

Error obtaining UI hierarchy Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist

I am testing my app with adb, but i get this error when i execute "dump view hierarchy for uiautomator": Error obtaining UI hierarchy Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist! My…
Ale7
  • 401
  • 1
  • 5
  • 7
27
votes
10 answers

ant build : unable to locate tools.jar. Expected find it in C:\Program Files\Java\jre7\lib\tools.jar

I know that this question is popular, but no one of solutions can help me. I used this, this, this and this solutions, but no one help me. I want to implement uiautomator Tests and need to build my build.xml with ant, but get this strange error. I…
Rikki Tikki Tavi
  • 3,089
  • 5
  • 43
  • 81
24
votes
6 answers

How to use espresso to press a AlertDialog button

I want to press below button using Espresso, but I'm not sure how. Should I get the resource-id? Or how to set an ID to the AlertDialog?? @RunWith(AndroidJUnit4.class) public class ApplicationTest { @Rule public ActivityTestRule
22
votes
4 answers

Android - Independent Fragment UI testing tool

I've been looking for a way to test the UI of my Fragments separately (ie, independently from other fragments and activities) but I can't find a way to do it. In particular, let's say I have Fragment A, Fragment B and Fragment C. The only way…
21
votes
3 answers

UI Automator in project with minSdkVersion 9

im trying to use UI Automator in my project with minSdkVersion 9 and of course it not work because it target API 18. So Android Studio throws me this error: Error:(5, 5) uses-sdk:minSdkVersion 9 cannot be smaller than version 18 declared in library…
rafael
  • 732
  • 1
  • 11
  • 20
19
votes
6 answers

How can I get the parent of a view using uiautomator?

I'm trying to identify the parent view of an ui element so I can navigate through the UI freely. For example, in Settings app, I can find the view with the text "Bluetooth": UiObject btView = new UiObject(new UiSelector().text("Bluetooth")); Now,…
Gabriel Porumb
  • 1,661
  • 1
  • 12
  • 21
18
votes
7 answers

Android revoke permission at start of each test

I'm using Espresso and UIAutomator to write my test cases. I'm testing external storage permissions when it's denied and when it's allowed. I have different test cases which all require the permission to be revoked at the start of the test…
18
votes
20 answers

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…
Rancho
  • 976
  • 1
  • 8
  • 16
18
votes
7 answers

Unable to start uiautomatorviewer

I have : Android SDK Tools, Revision 22 Android SDK Platform, API 18 I go to /tools/ , I see there is one file named "uiautomatorviewer", I execute command uiautomatorviewer from terminal under the above path, however I got the…
Mellon
  • 37,586
  • 78
  • 186
  • 264
15
votes
2 answers

java.lang.SecurityException: Permission Denial: getIntentSender() when using UiAutomation in a test

Whenever I try to use UiAutomation in any test through getInstrumentation().getUiAutomation(), the process crashes with this exception: java.lang.SecurityException: Permission Denial: getIntentSender() from pid=30334, uid=2000, (need uid=1000) is…
Takhion
  • 2,706
  • 24
  • 30
1
2 3
60 61