Skip to main content

Appium Espresso driver

Learn how to run the Appium Espresso driver sessions on Browserstack App Automate.

Overview

Appium Espresso driver is a test automation server for Android that uses Espresso as the underlying test technology.

In this guide, you’ll learn about:

  1. Installing and configuring the Appium Espresso driver
  2. Common Issues

Prerequisites

  • Ensure that you have installed Appium Espresso driver (v2.7.0) on your system.
  • Ensure that you have a local Android real device (OS v7.0+).
  • Ensure that you have access to BrowserStack account credentials, namely Access Key and Username.

Installing and configuring the Appium Espresso driver

Follow these steps to install and configure the Appium Espresso driver:

Step 1: Clone the Appium repository

  1. Run the following commands in your terminal/command-line to clone the Appium repository and install the required dependencies.
     git clone -b releases/1.22 git@github.com:appium/appium.git 
     cd appium
    
  2. Replace the content in the package.json file of the cloned repository with the following content.
     "appium-espresso-driver": "2.7.0",
    
  3. In your terminal/command-line, run the following command.
     npm install
    

Step 2: Run local Appium Session

After you’ve cloned the repository, complete the following steps to run an appium session locally by connecting the local android device:

  1. In the cloned repository, run the following command:
     node build/lib/main.js --log-timestamp # Running Appium Server
    
  2. Run the following Appium Script in your editor.
     require 'json'
     require 'rubygems'
     require 'appium_lib'
     desired_caps = {
         'build': 'Ruby Appium Sample',
         'deviceName': '<local device name>',
         'platformVersion': '<local device os>',
         'platformName': 'android',
         'app': '/path/to/app',
         'automationName': 'Espresso',
         'showGradleLog': true,
         'forceEspressoRebuild': true,
         'espressoBuildConfig': {
     } }
     appium_driver = Appium::Driver.new({
         'caps' => desired_caps,
         'appium_lib' => {
             :server_url => "http://localhost:4723/wd/hub"
         }}, true)
     driver = appium_driver.start_driver
     sleep 60
     driver.quit
    
  3. After running the above script, capture the logline from the Appium Logs. A sample logline is as follows:
     Copying built apk from '/var/folders/22/9dxnk2js3274f0l_64mmd8bw0000gn
     /T/espresso-server-RZ8R704ZZCY/app/build/outputs/apk/androidTest/debug
     /app-debug-androidTest.apk' to '/var/folders/22
     /9dxnk2js3274f0l_64mmd8bw0000gn/T/io.appium.espressoserver.test_2.7.0
     _com.example.jetpackcomposeplayground_RZ8R704ZZCY.apk'
    
  4. Copy the APK at path1 / path2 to the destination directory (DESTINATION_APK) and upload the APK at DESTINATION_APK to Browserstack using the following endpoint:
     curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
     -X POST "https://api-cloud.browserstack.com/app-automate/espresso-
     server" \
     -F "file=@<DESTINATION_APK>"
     -F 'custom_id="<OPTIONAL_CUSTOM_ID>"'
    
  5. Copy the espresso_server_url from the response of curl request in Step 4.
  6. Refer to the guide to upload your main app and use it under the app capability.
  7. Run the Appium script using the following capabilities.
     caps = { ...
     'automationName': 'Espresso',
     'bstack:options': {
       ...
       'espressoServer': "<espresso_server_url>"
       ...
     }
     ... }
    

Common Issues

Whenever the Appium script in Step 2 (in the Step 2: Run local Appium Session) fails, error loglines are displayed in the Appium server logs (Step 2). In most cases, it could be dependency issues between the main app and the Espresso server app.

You can refer to other common issues here.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Talk to an Expert