Skip to main content
BrowserStack App Automate is a popular cloud-based device farm that provides access to thousands of real mobile devices for testing. This guide shows you how to run Patrol tests on BrowserStack.

Overview

BrowserStack App Automate allows you to run your Patrol tests on real Android and iOS devices in the cloud. You can test across different device models, OS versions, and configurations without maintaining physical devices.
BrowserStack offers both real devices and emulators/simulators. For the most accurate testing, we recommend using real devices.

Prerequisites

1

Create BrowserStack account

Sign up for a BrowserStack account if you don’t have one already.
2

Get your credentials

Retrieve your username and access key from BrowserStack’s account page.
3

Set environment variable

Export your credentials as an environment variable:
export BS_CREDENTIALS="YOUR_USERNAME:YOUR_ACCESS_KEY"
Add this to your shell profile (~/.zshrc or ~/.bashrc) to persist it:
echo 'export BS_CREDENTIALS="YOUR_USERNAME:YOUR_ACCESS_KEY"' >> ~/.zshrc
source ~/.zshrc

Setup for Android

1

Update test runner

Modify your app-level build.gradle or build.gradle.kts file to use the BrowserStack-specific test runner:
android {
  // ...
  defaultConfig {
    // ...
    testInstrumentationRunner "pl.leancode.patrol.BrowserstackPatrolJUnitRunner"
  }
  // ...
}
The BrowserstackPatrolJUnitRunner is a specialized test runner that integrates with BrowserStack’s infrastructure and provides better test reporting.
2

Sync Gradle

After making this change, sync your Gradle files:
cd android && ./gradlew --refresh-dependencies
That’s it for Android! You can now proceed to running tests.

Setup for iOS

Before configuring BrowserStack for iOS, you must complete the Setup for physical iOS devices guide.
BrowserStack requires tests to use Xcode test plans. Follow these steps to convert your project:
1

Open Xcode

Open your iOS project in Xcode:
open ios/Runner.xcworkspace
2

Edit the scheme

Click on the scheme selector in the toolbar and select Edit Scheme…Edit scheme
3

Convert to test plans

In the scheme editor:
  1. Go to the Test tab
  2. Click Convert to use Test Plans…
Convert to test plans
4

Create from scheme

Select Create from Scheme when prompted:Create from scheme
5

Name the test plan

Important: Name the test plan exactly “TestPlan” (case-sensitive) and save it to the project root:Rename to TestPlan
The test plan must be named “TestPlan” to work with the bs_ios script.
Make sure your project name is “Runner” and the scheme is named “Runner” - these are the default names for Flutter projects and are expected by BrowserStack.

Running Tests

You have two options for running tests on BrowserStack: using automated scripts (recommended) or manually via API.

Viewing Results

After scheduling a test execution, view the results in the BrowserStack App Automate Dashboard. The dashboard provides:
  • Live test execution videos
  • Device logs
  • Network logs
  • Screenshots at each step
  • Crash reports
  • Performance metrics

Available Devices

To see all available devices and OS versions, check the BrowserStack Devices List. Popular device configurations:
[
  "Google Pixel 7 Pro-13.0",
  "Google Pixel 6-12.0",
  "Samsung Galaxy S23-13.0",
  "Samsung Galaxy S21-11.0",
  "OnePlus 9-11.0"
]
[
  "iPhone 14 Pro-16",
  "iPhone 14-16",
  "iPhone 13-15",
  "iPhone 12-14",
  "iPad Pro 12.9 2022-16"
]

Best Practices

Use Real Devices

Always test on real devices rather than simulators for the most accurate results.

Target Popular Devices

Focus your testing on the most popular devices among your user base.

Organize with Projects

Use the BS_PROJECT environment variable to organize tests by project in the dashboard.

Review Videos

Always review test execution videos to understand failures quickly.

CI/CD Integration

Integrate BrowserStack into your CI/CD pipeline:
name: BrowserStack Tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Flutter
        uses: subosito/flutter-action@v2
        
      - name: Install mobile-tools
        run: |
          brew tap leancodepl/tools
          brew install mobile-tools
          
      - name: Run Android tests
        env:
          BS_CREDENTIALS: ${{ secrets.BS_CREDENTIALS }}
          BS_PROJECT: ${{ github.repository }}
        run: bs_android --target integration_test/app_test.dart

Troubleshooting

Verify your credentials are correct:
echo $BS_CREDENTIALS
Make sure it’s in the format USERNAME:ACCESS_KEY with no extra spaces or quotes.
The device you specified might not be available in your BrowserStack plan or might be busy. Check:
  • The devices list for correct device names
  • Your BrowserStack plan’s device access
  • Try a different device or wait and retry
If app upload fails:
  • Check that the APK/IPA file exists at the specified path
  • Ensure the file size is under BrowserStack’s limits (currently 4GB)
  • Verify your BrowserStack plan allows app uploads
If tests are uploaded but don’t execute:
  • Verify you’re using the correct test runner (BrowserstackPatrolJUnitRunner for Android)
  • For iOS, ensure the test plan is named “TestPlan”
  • Check the BrowserStack dashboard for error messages

Next Steps

Firebase Test Lab

Compare with Google’s Firebase Test Lab

LambdaTest

Explore another cloud testing platform

Resources

Build docs developers (and LLMs) love