Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy

Specify devices

You can run your Espresso automation tests on a wide range of Android devices on BrowserStack. These are not simulators or emulators but physical devices hosted in our data centers. You can specify the device attributes either with or without using a regular expression (regex).

Specify device attributes

While executing your Espresso tests, you can specify a list of Android devices to run your tests on. In order to do so, you need to pass the devices parameter in the REST API request to start your test execution. You can set its value as shown in the table below.

REST API endpoint :

POST /app-automate/espresso/v2/build
Parameter Description Values
devices Specify one or more devices to run tests on. This is required. List of device and OS versions to test on. Each value in the list follows this format : <devicename>-<os version>. Use the device selector below to see the value for your desired devices.
Select device
This device is not available in the free plan. Please upgrade to paid plan.
 

You can easily execute your Espresso tests on multiple devices as shown in an example cURL request below :

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" \
-d '{"devices": ["Samsung Galaxy S8-7.0", "Google Pixel 2-9.0", "Samsung Galaxy Note 10-9.0"], "app": "bs://f7c874f21852ba57957a3fdc33f47514288c4ba4", "testSuite": "bs://e994db8333e32a5863938666c3c3491e778352ff"}' \
-H "Content-Type: application/json"

Use regular expressions to specify device attributes

You can use regular expressions (regex) to select devices to test on instead of providing specific device models in the devices parameter using the builds REST API. Based on the regex you pass, the first available device is allocated from the device pool that matches your specifications. By widening your search through regular expressions, you get better test execution speed by reducing queuing and device tier limits.

The following table provides information on how to use regular expressions for specifying device attributes:

Parameter Description Sample values
devices Required
- device is required.
- os_version is optional. The latest OS version is allocated for the device model if you do not pass this key.
"devices": [{ "device": "Samsung Galaxy.*", "os_version": "[89]"}, {"device": "Google Pixel 3$", "os_version": ".*"}]
Samsung .* allocates any Samsung device,
Google Pixel 3$ allocates Google Pixel 3 only.

Example cURL request where a regular expression has been used to specify tests to run on any 2 Galaxy devices with OS version 11.0:

Here are some use cases of the using regular expression to specify device attributes:

Use case Number of parallels consumed Parameter structure
Run test suite on any Galaxy device with OS version 11.0 1 "devices": [{"device": "Samsung Galaxy .*", "os_version": "11.0"}]
Run test suite on any 2 Galaxy devices with OS version 11.0 2 "devices": [{"device": "Samsung Galaxy .*", "os_version": "11.0"}, {"device": "Samsung Galaxy .*", "os_version": "11.0"}]
Run test suite on any 1 Galaxy device with OS version 11.0 and any 2 Android 8 or Android 9 devices 3 "devices": [{"device": "Samsung Galaxy .*", "os_version": "11.0"}, {"device": ".*", "os_version": "[89]"}, {"device": ".*", "os_version": "[89]"}]

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
Download Copy