Thursday 29 September 2016

Record Test Cases using Espresso Test Recorder

Hi everyone it gives me immense pleasure to share with all that Android Studio 2.2 has been launched and as Android App Tester there is something very useful has been launched for us that is Espresso Test Recorder. In our Espresso Tutorials we have seen how to code and run Espresso test cases plus we have studied writing test cases for WebViews and Intents and much more. 

In this post I want to share with you about newly launched Android's Espresso Test Recorder and how we can us it effectively to record and run our test cases. If you are a Manual Tester and not comfortable then you must learn this as it is very simple and quick to learn feature of Espresso. If you are Automation Tester and already using Espresso should must try it out it will reduce you work load and helps you in faster test case development.

Video Tutorial is Also Available - 


What is Espresso Test Recorder ?

Espresso is Android's Instrumentation Test Framework which allows developers and testers to write UI test cases to test functionality of the app. Espresso Test Recorder is new feature introduced in Android Studio 2.2 which allows user to Manually perform steps in an device and add assertions to record test cases. 

Pros of Espresso Test Recorder -
1. Allow Us to create effective UI based Test Cases with user interactions.
2.We can capture assertions and interactions without accessing app's structure directly which increases execution speed and optimizes test case.
3.It saves lot of time to search for locators and then writing test cases.
4. It supports multiple assertions making more reliable test cases.
Cons of Espresso Test Recorder -
1. Currently does not Support Recording of WebViews interactions.
2.  Once We complete Recording once for next time Recording it launches the app there is no API to control such behavior.
3. Cannot record Assertions for Toast Messages

Step by Step Recording first Espresso Test Case -

1. Android Studio 2.2
2. Java 8
3. Environmental variable Set up for JAVA_HOME and Android_HOME

Mobile Device Settings
1. Go to Phone's Settings
2. Developers option
3. Turn off Windows Animator Scale, Transition Animator Scale & Animation Duration Scale.

Recording UI Interactions
1. Launch Android Studio 
2. Click on Start New Android Studio Project
3. Give Application Name as EspressoTestRecorder
4. Click on Next

5. Click on Next

6. Select Blank Activity and click on Next

7. Your Android Project will be opened
8. Go to Run -> Record Espresso Test 

9. Select a Device and click on OK
10. Check your device it will say "Waiting for Debugger" after installing the application when the window closes (Do not click on Force Close) start performing Tap and Type Events on the Mobile Application.

Record Assertions
1. Click on Add Assertions
2. It will take Screenshot of the Device and display it on the screen.

3. In Edit Assertions Section you can select what type of assertions you want to add.

4. Click on Save Assertions.
5. Then Click on Complete Recording to save your test case

Save The Test Case
1. A popup will appear with Name of the Activity on which test is recorded you can edit the name
2. Click on Save

3. The test case will be saved in Android ->app->package name with (androidTest)->TestClassName

Run the Test Case
1. Once you locate the Test Class right click on the name
2. Click on Run.

Isn't it simple and interesting to learn. Write your queries and questions in the comment section and spread the word about New Espresso Test Recorder to Ease work load. Happy Testing :-)


  1. Thank you's helpful

  2. Very helpful! running all the test classes one by one through package. So how to uninstall and install apk after excecuting each testclass..plz help :)

  3. I’m planning to start my blog soon, but I’m a little lost on everything. Would you suggest starting with a free platform like Word Press or go for a paid option? There are so many choices out there that I’m completely confused. Any suggestions? Thanks a lot.

    selenium training in bangalore|
    selenium training in chennai|

  4. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    java training in bangalore

    java training in chennai

    java training in bangalore