Integrate BrowserStack App Automate with Fastlane

Integrate your Appium test suite with Fastlane and BrowserStack device cloud for native and hybrid apps using our Fastlane plugin.


Fastlane is a tool to automate beta deployments and releases for iOS and Android apps. It handles tasks like generating screenshots, dealing with code signing, and releasing applications, etc. Add BrowserStack to the mix, and your mobile apps can be tested across 1100+ real devices. BrowserStack lets you integrate your Appium tests with Fastlane using a plugin that will allow you to upload your app to the BrowserStack servers and test on the BrowserStack real device cloud.

Getting started

Install plugin:

Add BrowserStack’s Fastlane plugin by executing the below command:

fastlane add_plugin browserstack

You can easily upload your app using BrowserStack Fastlane Plugin and execute your test on the BrowserStack cloud. In order to configure the plugin add below action in your Fastfile. You can also refer to the sample android project, which demonstrates the use of this plugin.

  browserstack_username: ENV["BROWSERSTACK_USERNAME"],
  browserstack_access_key: ENV["BROWSERSTACK_ACCESS_KEY"],
  file_path: "<path_to_your_apk_or_ipa_file>",
  custom_id: "<custom_id_name>"

Note: custom_id is optional. You can upload multiple builds under the same custom_id. Use custom_id in the app capability for Appium to always pick the last uploaded build. The file_path parameter is not required if the app was built in the same lane with the help of the Gradle or Gym plugin.

Once the app upload is successful, the app id of the app will be stored in an environment variable “BROWSERSTACK_APP_ID” and it can be accessed in your tests in the following way :

String userName = System.getenv("BROWSERSTACK_USERNAME");
String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
String app = System.getenv("BROWSERSTACK_APP_ID");

public static void main(String args[]) throws MalformedURLException, InterruptedException {
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("device", "Samsung Galaxy S8");
    caps.setCapability("app", app);
    caps.setCapability("build", "MyBuild");

driver = new AndroidDriver(new URL("https://"+userName+":"+accessKey+""), caps);
userName = process.env.BROWSERSTACK_USERNAME
accessKey = process.env.BROWSERSTACK_ACCESS_KEY
app =  process.env.BROWSERSTACK_APP_ID

var capabilities = {
    "browserstack.user" : userName,
    "browserstack.key" : accessKey,
    "device" : "Samsung Galaxy S8",
    "app" : app,
    "build" : "MyBuild"

driver = wd.promiseRemote("");

  //Write your code here
  .fin(function() { return driver.quit(); })
userName = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME");
accessKey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY");
app = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID");

DesiredCapabilities caps = new DesiredCapabilities();
caps.SetCapability("browserstack.user", userName);
caps.SetCapability("browserstack.key", accessKey);
caps.SetCapability("device", "Samsung Galaxy S8");
caps.SetCapability("app", app);
caps.SetCapability("build", "MySampleBuild");

AndroidDriver driver = new AndroidDriver(new Uri(""), caps);
$user_name = getenv("BROWSERSTACK_USERNAME");
$access_key = getenv("BROWSERSTACK_ACCESS_KEY");
$app = getenv("BROWSERSTACK_APP_ID");

$capabilities = new DesiredCapabilities();
$capabilities->setCapability("device", "Samsung Galaxy S8");
$capabilities->setCapability("app", $app);
$capabilities->setCapability("build", "MySampleBuild");

$driver = RemoteWebDriver::create("https://"+user_name+":"+access_key+"", $capabilities);
user_name = os.getenv("BROWSERSTACK_USERNAME")
access_key = os.getenv("BROWSERSTACK_ACCESS_KEY")
app = os.getenv("BROWSERSTACK_APP_ID")

desired_cap = {
 'device': 'Samsung Galaxy S8',
 'app': app,
 'build': 'MyBuild'

driver = webdriver.Remote("https://"+user_name+":"+access_key+"", desired_cap)

desired_caps = {
    'device': 'Samsung Galaxy S8',
    'app': app,
    'build': 'MyBuild'

appium_driver ={
	'caps' => desired_caps,
	'appium_lib' => {
    :server_url => "https://#{user_name}:#{access_key}"
	}}, true)

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