Fastlane

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

Introduction

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.

upload_to_browserstack_app_automate(
  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+"@hub-cloud.browserstack.com/wd/hub"), 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("https://hub-cloud.browserstack.com/wd/hub");

driver
  .init(capabilities)
  //Write your code here
  .fin(function() { return driver.quit(); })
  .done();
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("https://hub-cloud.browserstack.com/wd/hub"), 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+"@hub-cloud.browserstack.com/wd/hub", $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+"@hub-cloud.browserstack.com/wd/hub", desired_cap)
user_name = ENV['BROWSERSTACK_USERNAME']
access_key = ENV['BROWSERSTACK_ACCESS_KEY']
app =  ENV["BROWSERSTACK_APP_ID"]

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


appium_driver = Appium::Driver.new({
	'caps' => desired_caps,
	'appium_lib' => {
    :server_url => "https://#{user_name}:#{access_key}@hub-cloud.browserstack.com/wd/hub"
	}}, true)