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
14
votes
3 answers

Android Espresso - Web browser

I have a question I want to test whether after button click the web browser is beign launched using espresso. And the question is: is it even possible to test such thing? If so any ideas how would I do that?
user3274539
  • 687
  • 2
  • 8
  • 18
14
votes
2 answers

Espresso - Asserting a TextView with async loaded data

I'm writing a UI test with Google Espresso for Android and I'm stuck on how to assert a TextView text, which content is asynchronously loaded from a web service. My current code is: public class MyTest extends BaseTestCase{ public…
Bolhoso
  • 895
  • 1
  • 7
  • 14
13
votes
6 answers

Activity never becomes requested state "[DESTROYED, RESUMED, STARTED, CREATED]" (last lifecycle transition = "PRE_ON_CREATE")

This is not a duplicate question. I have already looked at similar questions. I have added the questions I have referred to at the last. My problem is that the test executes, but I have to open the app manually for every test. You can see that I…
Abhimanyu
  • 11,351
  • 7
  • 51
  • 121
13
votes
2 answers

attribute android:forceQueryable not found in Android studio when running Espresso test

I have recorded my android app Espresso test using android studio Record Espresso Test option in Run menu. In the end of the record I saved the test with a my own file name. Once click the save button, IDE automatically created the file in…
13
votes
2 answers

How to test fragment navigation in Espresso with Navigation Component (Fragment to Fragment)?

I want to test fragment navigation (from a fragment to another) when I click a button but in the test, it never navigates to the destination. When I test it manually it works correctly. Also I'm using Navigation Component. I researched and found…
13
votes
1 answer

FragmentScenario configuration - Binary XML file line, Error inflating class while testing with espresso

Inflating error while trying to use FragmentScenario with launchFragment and launchFragmentInContainer if using material component in XML. android.view.InflateException: Binary XML file line #41: Binary XML file line #41: Error inflating class…
MatPag
  • 41,742
  • 14
  • 105
  • 114
13
votes
1 answer

Error performing 'single click - At Coordinates: 647, 1335 and precision: 16, 16'

Espresso is unable to perform any action on the app at the right corner of any device.It throws below error. I have tried below code: onView(withId(R.id.mapHomeSearch)).perform(click()); I have also tested it with closing the keyboard, scrolling,…
13
votes
2 answers

How to inject Mocked Presenter of Activity in Instrumentation testing with Espresso

I have been trying this for a week. And I have crawled every article available but their implementations or examples fall short or stop at the steps of Espresso Tests. My Android Application follows MVP architecture (And is in Java) Scenario:…
yUdoDis
  • 1,098
  • 6
  • 15
13
votes
1 answer

Espresso check if no dialog is displayed

I have a method that checks several conditions, and calls another activity when they are satisfied. When a condition isn't satisfied, it should display an error dialog (which is currently using a DialogFragment to display an alert dialog). The…
Matthew
  • 7,440
  • 1
  • 24
  • 49
13
votes
1 answer

How to place Android (instrumentation) test files outside of project directory?

I have an Android project (generated by Cordova) that I want to add (instrumentation) tests to. It has only one MainActivity.java that should be tested. Normally this means adding some dependencies to build.gradle and creating a file…
13
votes
2 answers

Espresso Test Failing: No interface method trackUsage() in UsageTracker.java

I'm receiving a runtime error No interface method trackUsage() in UsageTracker.java when the lines run in the Espresso test to scroll to a certain element in the RecyclerView list: …
AdamHurwitz
  • 9,758
  • 10
  • 72
  • 134
13
votes
1 answer

Select Date from Calendar in Android Espresso

I am testing an Android app with Espresso. I have an EditText widget with androidInputType=date. When I touch this control with my finger, a calendar pops up for me to select the date. How do I automate this in Espresso? I've looked all over the…
Ken DeLong
  • 929
  • 2
  • 8
  • 27
13
votes
1 answer

Android Espresso doesn't wait for fragments to load

I'm just getting started with Espresso for testing Android apps, but I'm having some trouble. I have an Activity with a button that replaces a fragment in the usual way: public void onClick(View v) { final FragmentTransaction t =…
Ken DeLong
  • 929
  • 2
  • 8
  • 27
13
votes
2 answers

How to get code coverage reports from google Firebase for Android Espresso tests

Based on this documentation - https://developer.android.com/studio/test/command-line.html#AMOptionsSyntax it is possible to get code coverage results back from Firebase lab. Some folks in #test-lab at firebase-community.slack.com are able to get it…
satyajit
  • 1,470
  • 3
  • 22
  • 43
13
votes
2 answers

Testing internet connectivity error handling in Android Studios with Espresso on Emulator

I am writing Instrumentation tests for my app on Android Studios testing on an emulator with Espresso. I need to disable the internet from within the test to make sure my error handling functionality works when the user does not have internet…
Drifting
  • 131
  • 1
  • 4