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
2
votes
2 answers

Android Unit test Xml.newSerializer() always return null

I am trying to unit test in Android a class that uses XmlSerializer but for some reason, Xml.newSerializer always returns null. The app code that uses xmlSerializer runs fine though. Does anyone know why it only returns null when unit…
c 2
  • 1,127
  • 3
  • 13
  • 21
2
votes
2 answers

How assert a BottomNavigationItemView is checked with Espresso?

BottomNavigationItemView implements the ItemView interface which has the setChecked() method. I tried to assert with Espresso that one itemView is checked but I got the same error, whatever my expected value is, isChecked() or isNotChecked(). My…
oldergod
  • 15,033
  • 7
  • 62
  • 88
2
votes
4 answers

Espresso test: How to open my application back after opening the recent apps?

I want to open my application back while writing an Espresso test case after opening recent apps by calling pressRecentApps() method. Is there a way to do this except of simulating a click by coordinates?
X-HuMan
  • 1,488
  • 1
  • 17
  • 37
2
votes
1 answer

Espresso Swipe on List Item of RecyclerView present inside a ViewPager

A ViewPager contains a RecyclerView. I am attempting to swipe an item in that RecyclerView, but unfortunately at times,the ViewPager gets swiped. Is this a bug in Espresso? The following code has been used to achieve…
JGPhilip
  • 1,388
  • 17
  • 19
2
votes
1 answer

Use Espresso to check contents of a web page loaded in the browser

I currently have a test which simulates clicking on a button in a dialog box which then loads a Google Forms document from my Google Drive: @Test public void testTakeSurveyNow() throws UiObjectNotFoundException { …
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
2
votes
0 answers

espresso times out on CookieManager.getInstance().setCookie(name, value)

I'm writing an espresso test for a login activity that sets cookies: CookieManager.getInstance().setCookie(name, value) But the test hangs at the above code then times out. Looking into the setCookie code I think it calls some native jni method. I…
Bing Qiao
  • 451
  • 1
  • 5
  • 14
2
votes
1 answer

It is possible to test widget with Espresso

I'm writing tests for my app, and one part is involving a widget. I can't find anything on the subject: it is possible to automatically test widgets with Espresso?
Geob-o-matic
  • 5,940
  • 4
  • 35
  • 41
2
votes
4 answers

Testing Google Android Places Autocomplete with Espresso

I'm struggling with instrumental ui test of a PlaceAutocomplete API, provided by Google. What I'm trying to test is ability to open AutoComplete Activity (fired with proper button), enter some text, pick result from given list and check if picked…
2
votes
1 answer

Espresso click on every element with a certain id

I have several buttons in my app with the same Id, I would like Espresso to click on all of them. These are basically collapse/expand buttons and thus I want the UI test to expand all elements in the view. I am always…
MichelReap
  • 5,630
  • 11
  • 37
  • 99
2
votes
1 answer

Espresso for ui-testing while doing network calls (RxJava-Project)

I recently started with UI testing on android and I am using Espresso for that. How can I wait for my data calls to complete? I am using RxJava and espresso is not having an idling resource for Rxjava. So I noticed that I can do my own Idling…
NullPointer
  • 1,250
  • 2
  • 12
  • 17
2
votes
1 answer

Mockito exception when Espresso added to project

I was successfully using Mockito in my project, then I decided to add some Espresso testing (As described here:https://developer.android.com/training/testing/ui-testing/espresso-testing.html#build) and I am stuck - when I add espresso to my…
Jeni
  • 1,088
  • 12
  • 30
2
votes
1 answer

Inject OkHttp using dagger2 in AndroidTest class for regestering OkHttp3IdlingResource

I have an app built with Retorift2 + Dagger2. I started to write Android UI tests using Espresso. To wait for a netwoking calls I need to register an IdlingResource. I have added dependency to OkHttp3IdlingResource. I need to Inject a OkHttp in my…
Vadims Savjolovs
  • 2,618
  • 1
  • 26
  • 51
2
votes
2 answers

How to monitor Android network performance?

We want to do network performance monitoring by monitoring the api calls. Currently we are using Android Network monitoring which is integrated with Android Studio. There are some problem with this framework. It can only give the amount of data…
2
votes
2 answers

Espresso unit test: How to disable animation in code

I already did these steps To avoid flakiness, we highly recommend that you turn off system animations on the virtual or physical device(s) used for testing. On your device, under Settings->Developer options disable the following 3 settings: Window…
Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107
2
votes
2 answers

Activity crash from missing argument with Junit ActivityTestRule

I have an Espresso test suite for UI tests that looks like this: @RunWith(AndroidJUnit4.class) public class SpecialUiTests { @Rule public final ActivityTestRule activity = new…
Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124