Enable Local Testing for Espresso tests
Enable Local Testing to test Android apps that retrieve data from local servers, private staging environments, or CI/CD nodes behind a firewall.
Get your Espresso tests to securely access local servers, staging environments, or firewalled CI/CD nodes by enabling BrowserStack Local Testing.
Establish a Local Testing connection
You can start a Local Testing connection through your command-line interface by following the steps below:
Start the tunnel
Navigate to the binary folder in your terminal and run:
./BrowserStackLocal --key YOUR_ACCESS_KEY
BrowserStackLocal.exe --key YOUR_ACCESS_KEY
Common enterprise flags: If you are behind a corporate proxy or need to force all traffic through the tunnel, use these flags:
-
Proxy:
--proxy-host <host> --proxy-port <port> -
Force Local:
--force-local(Routes all traffic through your machine, not just local URLs) -
Local Identifier:
--local-identifier <ID>(Required if running multiple tunnels in parallel)
Configure your Espresso execution
Once the tunnel is active (it stays open in your terminal), you must tell BrowserStack to route your Espresso build through it by setting the local capability to true.
| Capability | Description | Value |
|---|---|---|
local |
Test against internal/local servers |
true/ false Default: false |
REST API integration
Update your POST REST API request to the /build endpoint:
For more information on REST API usage, refer to the App Automate Espresso REST API documentation.
Best practices
The following best practices help you optimize your Local Testing experience:
| Feature | Recommendation |
|---|---|
| Execution order | Start the binary before triggering the cURL request. Kill the binary process only after the API returns the results. |
| Idling | If the tunnel is idle for too long, it may disconnect. Ensure your test starts within 5 minutes of opening the tunnel. |
| CI/CD | In Jenkins or GitHub Actions, use the BrowserStack SDK or the official plugins to automate the starting/stopping of this binary. |
Troubleshooting the connection
If your Espresso tests are failing to reach your local API, try the following steps:
-
Check the dashboard: On the App Automate Dashboard, look for the “Local Testing” indicator in your test session details.
-
DNS resolution: Try accessing your local server via IP address (e.g., http://192.168.1.5:8080) instead of
localhostif the app fails to resolve the host. -
Logs: Check the
local.logfile generated in the same directory as the binary for connection errors.

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!