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
43
votes
5 answers

Espresso UI testing doesn't recognize onView()

I have spent all day setting up Junit4 instrumentation tests with Espresso, but just can't seem to get that final step. No matter what I do it won't recognize the onView() method. I have tried multiple SDK/support-lib versions and so far nothing. I…
43
votes
10 answers

How to click on an item inside a RecyclerView in Espresso

I have a RecyclerView (R.id.recyclerView) where each row has an image (R.id.row_image) and a TextView. I want to click on the image in the first row. I've tried to use onData(..) but it doesn't seem to work.
Jacki
  • 431
  • 1
  • 4
  • 3
41
votes
7 answers

Espresso click menu item

I have a menu in the actionbar which I create through: @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE,…
user1583209
  • 1,637
  • 3
  • 24
  • 42
41
votes
4 answers

Selecting child view at index using Espresso

With Espresso when using a custom widget view with child image views, which Matcher type can I use to select the nth child? Example: +--------->NumberSlider{id=2131296844, res-name=number_slider, visibility=VISIBLE, width=700, height=95,…
ijunes
  • 582
  • 1
  • 4
  • 13
40
votes
6 answers

Espresso test fails with NoActivityResumedException often

EDIT: Updated description and error message and added some images. Still have this problem. I have a strange error that occur many times when running espresso tests. After a couple of successful test runs the tests starts failing with following…
peuhse
  • 1,688
  • 2
  • 20
  • 32
40
votes
1 answer

Testing ViewPager with Espresso. How perfom action to a button of an Item?

I have a ViewPager whith items containing only a picture and a button. I can't successfully interact with the UI of an item (Page) because, except the displayed picture, there is nothing to differentiate (from UI point of view) all items of the…
damson
  • 2,635
  • 3
  • 21
  • 29
38
votes
5 answers

Fragment Not Associated With A Fragment Manager

I am writing some instrumented tests for an app with one activity and multiple fragments using the Navigation Component. The code for my splash screen is as below: class SplashFragment : Fragment(), KodeinAware { override val kodein by…
38
votes
8 answers

Android Espresso: PerformException

I`m getting android.support.test.espresso.PerformException: Error performing 'send keyCode: 4, metaState: 0 key event' on view 'Animations or transitions are enabled on the target device. I read articles with same error but didnt find…
Andrey Danilov
  • 6,194
  • 5
  • 32
  • 56
37
votes
4 answers

Android Espresso - assert text on screen against string in resources

I have the following text in strings.xml resources file: My Text Normally in a application code, to use this text and display it on screen, I'm doing the…
klimos
  • 391
  • 1
  • 3
  • 5
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…
36
votes
3 answers

Espresso - Click by text in List view

I am trying to click on a text in a list view using Espresso. I know they have this guide, but I can't see how to make this work by looking for text. This is what I have…
Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
35
votes
4 answers

Espresso testing disable animation

@Test public void test3_PaySuccessful(){ init(); ViewInteraction amountEditText = onView( allOf(withId(R.id.et_amount), isDisplayed())); amountEditText.perform(replaceText("SGD 0.010"), closeSoftKeyboard()); …
kggoh
  • 742
  • 1
  • 10
  • 24
35
votes
4 answers

Espresso intent test failing

I'm learning android instrumentation testing with espresso. I have an app which has a drawer menu and there is a menu called About. I was testing click on that menu item and contents of activity. testfunction: @Test public void…
35
votes
7 answers

Click on not fully visible imageButton with Espresso

I have a custom ImageButton that is not fully visible, by design, so when I perform a click action I get this error: android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id:…
HowieH
  • 2,612
  • 2
  • 23
  • 26
34
votes
6 answers

android espresso login once before running tests

I've been trying to cover my Android app with tests and have started using espresso recently. Pretty impressed with it so far. However most of my app's functionality requires that users are logged in. And since all tests are independent, this…
source.rar
  • 8,002
  • 10
  • 50
  • 82