Run Appium Espresso driver sessions on App Automate
Combine Appium’s WebDriver protocol with Espresso’s native test engine to automate Android apps on BrowserStack App Automate.
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:
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.
Install and configure the Appium Espresso driver
Follow these steps to install and configure the Appium Espresso driver:
Step 1: Clone the Appium repository
- Run the following commands in your terminal/command-line to clone the Appium repository and install the required dependencies.
git clone -b 1.x git@github.com:appium/appium.git cd appium - Replace the content in the
package.jsonfile of the cloned repository with the following content."appium-espresso-driver": "2.7.0", - 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:
- In the cloned repository, run the following command:
node build/lib/main.js --log-timestamp # Running Appium Server - 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 => "https://localhost:4723/wd/hub" }}, true) driver = appium_driver.start_driver sleep 60 driver.quit - 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' - Copy the APK at
path1 / path2to the destination directory(DESTINATION_APK)and upload the APK atDESTINATION_APKto 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>"' - Copy the
espresso_server_urlfrom the response of curl request in Step 4. - Refer to the upload app documentation to upload your main app and use it under the
appcapability. - Run the Appium script using the following capabilities.
caps = { ... 'automationName': 'Espresso', 'bstack:options': { ... 'espressoServer': "<espresso_server_url>" ... } ... }
Common issues
When the Appium script in Step 2, Run local Appium session, fails, error loglines appear in the Appium server logs. In most cases, the failure is a dependency issue between the main app and the Espresso server app. Refer to other common issues.
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
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!