Questions tagged [android-espresso]

Espresso is a library which is used to write Android UI tests. It is also known as Google's Testing Tools For Android

Also called android-test-kit, Espresso helps to create faster UI tests for Android.

The core API is small, predictable, and easy to learn and yet remains open for customization. Espresso tests state expectations, interactions, and assertions clearly without the distraction of boilerplate content, custom infrastructure, or messy implementation details getting in the way.

Espresso tests run optimally fast! Leave your waits, syncs, sleeps, and polls behind and let Espresso gracefully manipulate and assert on the application UI when it is at rest. Enjoy writing and executing your tests today - try a shot of Espresso!

Useful links

3335 questions
24
votes
11 answers

Delegate runner 'androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner' for AndroidJUnit4 could not be loaded

I try to run Kotlin instrumentation tests for android. In my app/build.gradle: android { dataBinding { enabled = true } compileSdkVersion 28 defaultConfig { applicationId "com.myproject" …
Alexei
  • 14,350
  • 37
  • 121
  • 240
24
votes
8 answers

How to see the Android Orchestrator log?

I have a failing test in my suite and now I am using the Android Orchestrator, but all I get is this message: Test instrumentation process crashed. Check com.something.something_detail.SomeActivityTest#testAddSucceeds_activityIsFinished.txt …
Leandro Borges Ferreira
  • 12,422
  • 10
  • 53
  • 73
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
24
votes
2 answers

Testing endless scrolling RecyclerView with Espresso and RxJava

I have RecyclerView with endless scrolling. So when user reach last - 2 position in list, I call server for more data and during call in progress, I add one more item - progress one. Now, I'm trying to write decent UI test with Espresso which will…
Divers
  • 9,531
  • 7
  • 45
  • 88
24
votes
4 answers

Android Espresso error on button click

I'm trying to write some UI tests for an Android APP with the espresso framework. For now I'm just checking if all the elements are present on the splash screen and then I'm trying to click the login button. When the the button is clicked the test…
PeachMode
  • 397
  • 1
  • 4
  • 15
24
votes
5 answers

Espresso - click a single list view item

I tried doing the following: onView(allOf(withId(R.id.single_row_text), withText("Item1"))).perform(click()); But all I got is: android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (with id:…
philomath
  • 2,209
  • 6
  • 33
  • 45
24
votes
2 answers

Espresso select children of included layout

I have been using Espresso to carry out automated UI testing with an Android app. (I have been trying to find a resolution to the issue whilst at home from work, so I don’t have the exact examples and errors, but I can update tomorrow morning). I…
jordan_terry
  • 468
  • 1
  • 4
  • 12
24
votes
9 answers

Android Studio doesn't recognize Espresso classes

I'm running Android Studio 0.5.0 with Gradle 1.11. I'm trying to install Espresso library from com.jakewharton.espresso:espresso:1.1-r2. For some reason AS couldn't recognize Espresso classes after project synchronization. So every time I try to…
midnight
  • 3,420
  • 3
  • 36
  • 58
24
votes
9 answers

Android Espresso, Wake up device before test. How to use a custom manifest for test?

I've been writing tests with androids new espresso framework and find that it works well. One annoying thing (not particular to espresso) is that I have to make sure my screen is awake and unlocked for the tests to run. I found a workaround (through…
Matt Wolfe
  • 8,924
  • 8
  • 60
  • 77
23
votes
5 answers

java.lang.NoSuchMethodError: No static method registerDefaultInstance with Firebase Performance and Espresso Instrumented Tests

When I adding implementation 'com.google.firebase:firebase-perf-ktx:19.1.0' I cannot start espresso instrumented tests ("app" scheme building ok). When I trying to start Espresso test, I have Test running failed: Process…
Vladimir Fisher
  • 3,090
  • 2
  • 17
  • 23
23
votes
5 answers

Hilt Fragments must be attached to an @AndroidEntryPoint Activity. Found: class androidx.fragment.app.testing.FragmentScenario$EmptyFragmentActivity

I got following error when i run my unit test code. Caused by: java.lang.IllegalStateException: Hilt Fragments must be attached to an @AndroidEntryPoint Activity. Found: class androidx.fragment.app.testing.FragmentScenario$EmptyFragmentActivity at…
Cyrus
  • 8,995
  • 9
  • 31
  • 58
23
votes
3 answers

Android Espresso wait for text to appear

I am trying to automate an Android app that is a chatbot using Espresso. I can say that I am completely new to Android app automation. Right now I am struggled with waiting. If I use Thread.sleep, it works perfectly fine. However, I would like to…
Anna Puskarjova
  • 313
  • 2
  • 3
  • 6
23
votes
7 answers

How to click a clickablespan using espresso?

I have a textview with multiple clickable spans in it. I want to be able to test clicking these spans. I tried setting up a custom ViewAction that would find the clickablespans in the TextView and then match their text with the desired text and…
Captain Hammer
  • 243
  • 2
  • 7
23
votes
8 answers

Android Espresso : cannot resolve symbol AndroidJUnit4.class

I'm trying to create Espresso UI test inside the new Android project but I faced with the following problem. If I tried to create a empty test class: import android.content.Intent; import android.support.test.rule.ActivityTestRule; import…
redrom
  • 11,502
  • 31
  • 157
  • 264
23
votes
3 answers

Espresso how to wait for some time(1 hour)?

In my test case I have to record for 1 hour, in robotium solo.sleep(600000) had done my work, but In espresso I am confused with IdlingResource concept. I have to start recording and wait for some time(depending on the type of test) 15mins, 60mins…
Shivaraj Patil
  • 8,186
  • 4
  • 29
  • 56