Integrate Appium test suite with Fastlane
Integrate your Appium test suite with Fastlane and the BrowserStack device cloud for testing native and hybrid apps using our Fastlane plugin.
Fastlane is an open-source tool that automates beta deployments and releases for iOS and Android apps, handling tasks such as generating screenshots, code signing, and app releases.
BrowserStack’s Fastlane plugin lets you upload your app and run your Appium tests across more than 1100 real devices in the BrowserStack device cloud.
Prerequisites
Before you begin, ensure you have:
- A BrowserStack App Automate account with your username and access key.
- Fastlane installed and set up in your project.
- An Appium test suite for your native or hybrid app.
Integrate BrowserStack with Fastlane
Install the plugin
Add BrowserStack’s Fastlane plugin to your project:
fastlane add_plugin browserstack
Upload your app
Add the upload_to_browserstack_app_automate action to your Fastfile to upload your app to BrowserStack:
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>"
)
The action accepts the following parameters:
-
browserstack_username: Your BrowserStack username. -
browserstack_access_key: Your BrowserStack access key. -
file_path: Path to your.apkor.ipafile. Not required if the app was built in the same lane using the Gradle or Gym plugin. -
custom_id(optional): A custom identifier for your build. You can upload multiple builds under the samecustom_id, then set it in the Appiumappcapability to always pick the latest build.
For a working example, refer to the sample Android project, which demonstrates the use of this plugin.
Access the uploaded app in your tests
After a successful upload, the app ID is stored in the BROWSERSTACK_APP_ID environment variable. Access it in your tests as follows:
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)
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!