Get Espresso build information via App Automate API
Execute and manage your Espresso builds using the BrowserStack App Automate API. Run automated app tests on real mobile devices.
Each build represents an execution of your Espresso test-suite on one or more devices on BrowserStack. Use our REST API to execute and manage your test builds. In addition, you can fetch build status in real-time as well as obtain access to video recording and other test execution logs.
Execute a build
Start the execution of a new build on BrowserStack. While making a request, you must specify the application under test, Espresso test-suite as well as a list of devices to execute your tests on. In addition, you can specify a number of other parameters to customise test execution. Every build has a unique build_id associated with it. This is returned in the response to this endpoint.
Request parameters
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" \
-d '{"app": "bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3", "testSuite": "bs://89c874f21852ba57957a3fdc33f47514288c4ba1","project" : "Espresso_Test", "instrumentationOptions": {"foo": "Log.d ( "FOO", extras.getString ( "foo" ))"},"devices": ["Samsung Galaxy S20-10.0","Google Pixel 7-13.0"]}' \
-H "Content-Type: application/json"
-
app* String
Specify the application under test. Use
app_urlorcustom_idof a previously uploaded app. Learn more about app API -
testSuite* String
Specify an Espresso test-suite. Use
test_urlorcustom_idof a previously uploaded test-suite. Learn more about testSuite API -
instrumentationOptions* Object
Set of key-value pairs passed to the test instrumentation
-
devices* Array
List of devices to execute your tests on. Learn more about selecting devices
Example:['Samsung Galaxy S8-7.0', 'Google Pixel 3-10.0']
To run on any available device that matches a pattern, pass an object with adeviceregular expression and an optionalos_versionregular expression instead of aDevice-OSstring. If you don’t passos_version,devicemust be a regular expression, and a device with any OS version of the matching models can be allocated. Each object consumes one parallel.
Example:[{"device": "Samsung Galaxy .*", "os_version": "11.0"}]Learn more about selecting devices using regular expressions.
If you setdeviceSelectiontooneToOneinside theshardsparameter and every shard has its owndeviceinmapping, you can omit this parameter. -
shards Object
▶ SHOW VALUESSplit an Espresso test-suite into multiple shards and execute them in parallel.
-
numberOfShards* Integer
The total number of shards to split the test-suite into.
-
deviceSelection String
Specify if a shard should run on all specified devices (using
devicesparameter), on only one random device, or on one device that you choose for that shard.Possible Value Description allEach shard will run on all specified devices. Thus, the total number of parallel tests required for test execution will be equal to (numberOfShards * number of specified devices). This is default behaviour. anyEach shard will run on any one random device. Thus, the total number of parallel tests required for test execution will be equal to (numberOfShards) oneToOneEach shard runs on exactly one device: the deviceset in the shard’smappingentry. If a shard has nodevice, it runs on the device at the shard’s position in thedevicesparameter: the first shard on the first device, the second shard on the second device, and so on. If there are more shards than devices, the assignment wraps around to the first device. The position counts every shard, including shards that set their owndevice. Thus, the total number of parallel tests required for test execution is equal to (numberOfShards). -
mapping Array
▶ SHOW VALUESDetails of how test sharding should be handled. Each shard should have its corresponding mapping. This is optional parameter - if mapping is not provided, we will handle test sharding automatically.
-
name* String
Unique identifier for each shard.
Example:0,1 -
strategy* String
Strategy used to shard. The possible values:
Possible Value Description classAllows you to define a list of test classes to be executed in a particular shard. packageAllows you to define a list of test packages to be executed in a particular shard. annotationAllows you to run tests in a shard based on test annotations. sizeAllows you to run tests in a shard based on test size annoations (E.g. SmallTest, MediumTest, LargeTest). cucumberOptionsAllows you to run the test cases of a Cucumber-based Espresso test suite in a shard, filtered by tags, scenario name, or feature file path. -
values* Array or Object
Class/Package/Annotation/Size values depending on the type of
strategyselected.
Example:["com.android.dashboard.Home", "com.android.profile.addUser"]forclassstrategy.
For thecucumberOptionsstrategy, pass an object with thetags,name, orfeaturesfilters instead.
Example:{"tags": "@first"} -
device String or Object
Device to run this shard on. Applies only when
deviceSelectionis set tooneToOne, and is ignored for other values. Pass an exact device as aDevice-OSstring, or an object withdeviceand optionalos_versionregex patterns to run the shard on any available device that matches. An object must contain a regex pattern, such as.*or[34]. To run on a fixed device, use the exact string instead. Use the same format as the entries of thedevicesparameter and thedeviceof every other shard. If you set adevicefor every shard, you can omit thedevicesparameter.
Example:"Google Pixel 8-14.0"or{"device": "Google Pixel 8.*", "os_version": "14"}
-
-
- Show 42 more
-
project String
Unique identifier to logically group multiple builds together. Only letters (A-Z, a-z), digits (0-9), periods (.), colons (:), hyphens (-), square brackets ([]), forward slashes (/), at signs (@), ampersands (&), single quotes (‘), and underscores (_) are allowed, along with spaces. Any other character is replaced with a space, and leading and trailing spaces are removed. Maximum length is 100 characters. By default, it’s set to
Untitled Espresso Project. Learn more about organizing tests -
customBuildName String
A custom name for your build. Accepted characters are
A-Z,a-z,0-9,.,:,-,[,],/,@,&,',_. All other characters are ignored. Invalid names fall back to the default naming workflow. If you don’t setproject,customBuildNamecan be up to 100 characters. A longer name is rejected with aproject_name_length_invaliderror. Learn more about custom build names -
class Array
Filter test cases by selected classes in the test-suite. Specify a list of fully qualified Java class name(s).
Example:["com.android.foo.ClassA", "com.android.foo.ClassB"] -
package Array
Filter test cases by selected packages in the test-suite. Specify a list of fully qualified Java package name(s).
Example:["com.android.foo"] -
annotation Array
Filter test cases by selected annotations in the test-suite. Specify a list of fully qualified annotation(s).
Example:["com.android.foo.MyAnnotation"] -
size Array
Filter test cases of specific test size i.e tests annotated with @SmallTest, @MediumTest or @LargeTest in the test-suite. Specify a list of test size values (small/medium/large).
Example:["small", "medium"] -
cucumberOptions Object
▶ SHOW VALUESFilter and run the test cases of a Cucumber-based Espresso test suite, and generate test reports. This parameter is used only when the test suite is a Cucumber suite. Otherwise, it’s ignored without an error. Unsupported
pluginsvalues are also ignored, and the request fails only if none of them are valid. The total length ofcucumberOptionscan be up to 1000 characters. Learn more about running Cucumber-based Espresso tests-
features Array
Paths of the feature files or directories to run. To run the scenarios written within certain lines of a feature file, add the line numbers after the file path.
Example:["features/multiplication", "features/addition/decimal/add.feature:4:8"] -
tags String
Run the test cases annotated with the specified tags.
Example:@Sum -
name String
Regular expression to match the names of the test scenarios to run.
Example:addition -
plugins Array
Formats of the test report to generate. The possible values:
Possible Value Description prettyGenerate the test report in the Pretty format. jsonGenerate the test report in the JSON format. junitGenerate the test report in the XML format. htmlGenerate the test report in the HTML format. Example:
["html", "junit"]
-
-
singleRunnerInvocation String
Execute all test cases together with a single test runner invocation. By default, it’s set to
false. Learn more about singleRunnerInvocation API -
useOrchestrator Boolean
Enable the Android test orchestrator for a build that uses
singleRunnerInvocation. To clear app data after each test in such a build, set this parameter andclearPackageDatatotrue. By default, it’s set tofalse. Learn more about clearing app data -
retryTestsOnFailure Boolean
Set to
trueto automatically rerun failed test cases. Learn more about rerunning failed tests -
testIterations Integer
Maximum number of retry attempts for a single failed test, up to a maximum of 5. The reruns stop as soon as the test passes. Use with
retryTestsOnFailure. By default, it’s set to1. -
testOrchestrationOptions Object
▶ SHOW VALUESConfigure test orchestration strategies for the build, such as fail fast and run failures only.
-
abortBuildOnFailure Object
▶ SHOW VALUESStop the build automatically once a specified number of tests fail. A test counts as failed only after all its retries are exhausted. Not supported when
singleRunnerInvocationoruseOrchestratoris set totrue.-
enabled* Boolean
Set to
trueto enable fail fast. SettingenabledtotruewithoutmaxFailuresfails validation. -
maxFailures* Integer
Number of failed tests that stops the build. Accepts an integer from
1to1000.
-
-
rerunPreviouslyFailed Object
▶ SHOW VALUESStart a new build that runs only the tests that failed in a previous, completed build of the same test suite. Not supported when
singleRunnerInvocationoruseOrchestratoris set totrue. Tests that aren’t run are reported with the statusnot-run (retry-failures).-
enabled* Boolean
Set to
trueto enable run failures only. -
sourceBuildId String
The 40-character ID of a completed build whose failed tests you want to rerun. The build must belong to the same group and framework. If you omit it, BrowserStack searches your last 50 builds for the newest completed build that matches the new build’s project, framework, build name (
customBuildName, or the app name if it isn’t set), test suite (custom ID or file name), andshardIndex. Pass it explicitly if more than one build of the test suite can run at the same time.
-
-
-
callbackURL String
Specify a callback URL to enable BrowserStack to notify you upon the completion of your build.
-
projectNotifyURL String
Specify a callback URL to enable BrowserStack to notify you upon the completion of all builds under the given project. You will receive a callback if no new builds triggered for 5 mins and all existing builds have finished execution.
Note: Set this parameter along with the
project parameter. -
networkLogs Boolean
Capture network logs (data such as network traffic, latency, HTTP requests and responses in the HAR format) for your test execution. By default, it’s set to
false. -
networkLogsOptions Object
▶ SHOW VALUESConfigure what the network logs capture. Use with
networkLogsset totrue.-
captureContent Boolean
Set to
trueto capture the response payload in the network logs. By default, it’s set tofalse.
-
-
deviceLogs Boolean
Capture device logs (system logs specific to your application generated by Android) for your test execution. By default, it’s set to
false. -
enableSpoonFramework Boolean
Capture screenshots using the Spoon framework.
-
debugscreenshots Boolean
Capture screenshots using App Automate’s native screenshot feature. Check out the espresso-browserstack sample repository for more details on using the native screenshot feature.
-
video Boolean
Enable or disable video recording for your test execution. By default, it’s set to true.
-
appProfiling Boolean
Capture detailed app performance metrics such as frames per second, Application Not Responding (ANR) rate, app and page load times, and device resource usage for your test execution. By default, it’s set to
false. -
coverage Boolean
Generate a code coverage report for your test execution. Enable code coverage with JaCoCo in your Android project first. By default, it’s set to
false. Learn more about code coverage reports -
sessionData Boolean
Collect the files your tests save to the
/sdcard/Download/assets/session_datadirectory on the device, so you can download them as a ZIP archive after the session ends. You can save up to 100 files, with a total size of up to 500 MB. The archive is available for 30 days. By default, it’s set tofalse. Learn more about downloading post-test reports -
gpsLocation String
Simulate the location of the device to specific GPS coordinates. Specify latitude followed by longitude. Acceptable range for latitude is -90 to +90 and for longitude is -180 to +180. Learn more about gpsLocation API.
Example:40.730610,-73.935242 -
geoLocation String
Test your app behavior from different countries using IP geolocation. Specify the two letter country code. Learn more about geoLocation API.
Example:CNfor China,FRfor France. -
networkProfile String
Simulate different network conditions while testing your app.
Example:2g-gprs-good,2g-gprs-lossy. View the list of supported network profiles. To send the device offline, set it tono-networkorairplane-mode. Set it toresetto restore BrowserStack’s default network configuration. -
customNetwork String
Simulate custom network condition while testing your app. Specify download speed (kbps), upload speed (kbps), latency (ms), packet loss (%).
Example:1000, 1000, 100, 1 -
language String
Set the language of the app under test.
Example:fr(for French) -
locale String
Set locale to test the localized version of your app.
Example:fr_CA(for French-Canada) -
timezone String
Configure tests to run on a custom time zone. Not supported on Xiaomi, Huawei, Oppo, and Vivo devices. Available only with a BrowserStack Paid plan.
Example:UTC,New_York(for America/New_York),La_Rioja(for America/Argentina/La_Rioja). Learn more about localization options -
appStoreConfiguration Object
Set credentials for Google account login. You need to pass:
Possible Value Description usernameUsername of your Google account passwordPassword of your Google account Example:
{"username":"xyz@gmail.com","password":"xyz@123"} -
deviceOrientation String
Set the screen orientation of the mobile device. Specify
portraitorlandscape. By default, it’s set toportrait. -
acceptInsecureCerts Boolean
Set this parameter to true to avoid invalid certificate errors while using self-signed certificate to test your app. By default, it’s set to false.
-
enableBiometric Boolean
Set this parameter to
trueto test biometric authentication, such as fingerprint and face ID, in your app. BrowserStack instruments your app to support interaction with biometric sensors. Available only under Device Cloud Pro, Device Cloud Pro + Visual Cloud, and Enterprise Pro plans. Learn more about biometric authentication -
uploadMedia Array
Set this parameter if you want to use your uploaded images or videos during test execution. Specify a list of
media_urlfor previously uploaded images or video. Learn more about uploadMedia API. -
local Boolean
Enable Local Testing for App Automate. With Local Testing enabled, test apps that retrieve data from servers on your local machine or other private network configurations.
-
localIdentifier String
If you are using the same account to test multiple applications, you can set up a named connection using the
localIdentifieroption. Example:Test123 -
allowDeviceMockServer Boolean
Set this parameter to
trueif your tests use a mock server on the device to mock API responses. If you use a mock server without this parameter, your tests might show a 503 error. Local Testing, network logs, and IP geolocation don’t work when this parameter is enabled. Learn more about using a mock server -
idleTimeout Integer
Use this parameter to specify the maximum time limit for which your test execution can remain idle. If it exceeds this threshold, your build status will change to timed out. Accepted range of values are between 60 seconds to 900 seconds. By default, it’s set to 900 seconds.
-
clearPackageData Boolean
Use this parameter to clear app data after every test run. Check out the clear app data guide to learn more.
-
buildTag String
Unique identifier to tag builds. You can filter builds by tag on the App Automate dashboard.
Example:Reg -
disableAnimations Boolean
Set this parameter to
trueto disable animations on the device.
Response attributes 200 application/json
Response
{
"message": "Success",
"build_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"
}
-
message String
Status of the request.
-
build_id String
A unique identifier for your test execution.
Example:5c5ab4338cec13aeb78f7a6977344556ac00bccd6
Get build status
Once a build is started, you can fetch its status using this endpoint. You can obtain the overall summary of your test execution as well as results for each individual test case.
Request parameters
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds/{build_id}"
-
buildID* String
Unique build ID for your Espresso test execution.
Example:57dd68e05f76ca3c9c0d4600fd78ae064fa537bb
Response attributes 200 application/json
Response
{
"id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0",
"framework": "espresso",
"duration": 83,
"status": "failed",
"input_capabilities": {
"devices": [
"Samsung Galaxy S20-10.0",
"OnePlus 7-9.0",
"Google Pixel 7-13.0"
],
"project": "Espresso_Test",
"app": "bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3",
"testSuite": "bs://89c874f21852ba57957a3fdc33f47514288c4ba1"
},
"start_time": "2020-06-04 07:43:49 UTC",
"app_details": {
"url": "bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3",
"bundle_id": "com.sample.browserstack.samplecalculator",
"version": "1.0",
"name": "app-debug.apk"
},
"test_suite_details": {
"url": "bs://89c874f21852ba57957a3fdc33f47514288c4ba1",
"bundle_id": "com.sample.browserstack.samplecalculator.test",
"version": "",
"name": "app-debugTest.apk"
},
"devices": [
{
"device": "Samsung Galaxy S20",
"os": "android",
"os_version": "10.0",
"sharding": false,
"sessions": [
{
"id": "e1c1b1c1de1d1c1e1ba1e1f1a1b11e1e11e1b1cd",
"status": "failed",
"start_time": "2020-06-04 07:44:07 +0000",
"duration": 62,
"testcases": {
"count": 9,
"status": {
"passed": 3,
"failed": 6,
"skipped": 0,
"timedout": 0,
"error": 0,
"running": 0,
"queued": 0
}
}
}]
},
{
"device": "OnePlus 7",
"os": "android",
"os_version": "9.0",
"sharding": false,
"sessions": [
{
"id": "e2c2b2c2de2d2c2e2ba2e2f2a2b22e2e22e2b2cd",
"status": "failed",
"start_time": "2020-06-04 07:44:10 +0000",
"duration": 59,
"testcases": {
"count": 9,
"status": {
"passed": 3,
"failed": 6,
"skipped": 0,
"timedout": 0,
"error": 0,
"running": 0,
"queued": 0
}
}
}]
},
{
"device": "Google Pixel 3",
"os": "android",
"os_version": "9.0",
"sharding": false,
"sessions": [
{
"id": "e3c3b7c8de1d1c2e3ba3e3f4a5b55e7e37e4b3cd",
"status": "failed",
"start_time": "2020-06-04 07:44:08 +0000",
"duration": 62,
"testcases": {
"count": 9,
"status": {
"passed": 3,
"failed": 6,
"skipped": 0,
"timedout": 0,
"error": 0,
"running": 0,
"queued": 0
}
}
}]
}
]
}
-
id String
Unique build ID for your test execution.
Example:4fc55a08d7e33651d962ad676c7d6a0a08902702 -
framework String
Name of the automation framework. This is set to Espresso.
-
duration Integer
Total duration for build completion (in seconds). This includes the time taken to install the app, test-suite, setting up the device along with the test execution time of all the test cases.
-
status String
Status of the your build execution. This is computed based on the status of every test case executed in your entire test-suite. Learn more about status API
-
input_capabilities Object
▶ SHOW VALUESDetails about the input parameters passed while starting the build execution.
-
devices Array
List of devices on which the build is executed.
Example:["Samsung Galaxy S20-10.0", "OnePlus 7-9.0"] -
project String
Name of your project which is set inside the
projectparameter inside the build execution API. -
app String
The
app_urlof the app uploaded on BrowserStack.
Example:bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3 -
testSuite String
The
test-urlof the test-suite uploaded on BrowserStack.
Example: bs://89c874f21852ba57957a3fdc33f47514288c4ba1
-
- Show 4 more
-
start_time String
Timestamp at which the build execution was started
-
app_details Object
▶ SHOW VALUESDetails about the application under test uploaded on BrowserStack
-
url String
The
app_urlof the app(.apk) file uploaded on BrowserStack. -
bundle_id String
Bundle ID or the package name of the app.
-
version String
Version code of the app that is defined in the Android manifest file.
-
name String
Name of your app(.apk) file.
-
-
test_suite_details Object
▶ SHOW VALUESDetails about the test-suite uploaded on BrowserStack
-
url String
The
test_urlof the test-suite(.apk) file uploaded on BrowserStack. -
bundle_id String
Bundle ID or the package name of the test-suite.
-
version String
Version code of the test-suite. The value is null.
-
name String
Name of your test-suite(.apk) file.
-
-
devices Array
▶ SHOW VALUESTest execution details for each device in the build.
-
device String
The name of the device.
-
os String
By default, this is set to Android.
-
os_version String
OS version.
-
sharding Boolean
Indicates if the sharding is enabled for this build.
-
sessions Array
▶ SHOW VALUESIf sharding is disabled, each session is the execution of your test on a single device. Thus, each device will have a single session. If sharding is enabled, each session is the execution of a single shard on a single device. Thus, each device will have multiple sessions (one for each shard).
-
id String
A unique session ID.
Example:09a018967ec8b2dc5dd391de1130f69463840039 -
status String
Status of this session.
-
start_time String
Timestamp at which the session execution started.
-
duration String
Duration of the session execution.
-
testcases Object
▶ SHOW VALUESTest case execution summary for this session.
-
count Integer
The total number of test-cases in this session.
-
status Object
▶ SHOW VALUESCount of test-cases by each status type.
-
passed Integer
Total count of test cases with explicit test assertions that marks the test as passed.
-
failed Integer
Total count of test cases with uncaught exceptions or explicit test assertions that marks test as failed.
-
skipped Integer
Total count of test cases that never got executed by the test runner.
-
timedout Integer
Total count of test cases that got timed-out.
-
error Integer
Total count of test cases that errored due to an unanticipated issue on BrowserStack.
-
running Integer
Total count of test cases that are currently under execution.
-
queued Integer
Total count of test cases that are queued for execution.
-
-
-
-
List recent builds
Fetch the most recent test builds sorted by timestamp. By default, it returns the last 10 builds. You can also filter builds by their project name or status, and paginate through your data.
Request parameters
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds"
# Limit the number of builds to be displayed using the "limit" parameter
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds?limit=5"
# Start the retrieval of records from a particular point using the "offset" parameter
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds?limit=2\&offset=2"
# Filter builds using the "status" parameter
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds?status=running"
# List builds using the project filter
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds?project=SampleBuild"
-
limit String
Specify the number of builds to fetch. The default value is 20. The value must be between 1 and 100. A value outside this range is set to the nearest limit.
-
offset String
Retrieve a list of builds from a particular point using the
offsetparameter. Useoffsetin conjunction with thelimitparameter. -
status String
Filter recent builds based on the build status. The possible values are
running,done,timeout, andfailed. -
project String
The project name of the builds. If the project doesn’t exist, the API returns a
404error.
Example:Espresso_Test
Response attributes 200 application/json
Response
[
{
"id": "5c5ab4338cec13aeb78f7a6977344556ac00bccd6",
"start_time": "2019-11-06 13:07:45 UTC"
},
{
"id": "235ab7338cec13ae6b8f7a6977344556ac00bccd6",
"start_time": "2020-06-04 07:43:49 UTC"
}
]
-
Array
▶ SHOW VALUESList of recent test builds sorted by timestamp
-
id String
Build ID.
-
start_time String
Timestamp at which the build execution is started.
-
Stop builds
If a test run stops due to a crash, you can stop the build by clicking the stop build button on the App Automate dashboard or using the REST API using the build ID of the build you want to stop. You can stop a build only while it’s running. Stopping is asynchronous, so the build status stays running until all its sessions stop. If you send another stop request during this time, the response is Build is already being stopped. After the build stops, a stop request returns a 422 error.
Request parameters
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds/<build_id>/stop"
-
buildID* String
The build ID of the build you want to stop.
Response attributes 200 application/json
Response
{"message":"Stopping build","stopped_session_count":1}
-
String
▶ SHOW VALUESSuccess message of build stop.
-
message String
Message, “Stopping build”.
-
stopped_session_count String
Number of sessions created in the build so far.
-
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.