Run Appium parallel tests with Python Behave | BrowserStack Docs (2023)

Parallel Testing is a feature of BrowserStack that allows you to run the same test or different tests simultaneously on different combinations of device and operating system versions. It will help you reduce the execution time of your test suite, resulting in faster build times and releases.

For example, the execution time of a test suite that takes30 minutesrunning sequentially can be reduced to as low as3 minutesrunning 10 parallel tests (assuming all your test cases take roughly the same time).

Use:Your App Automate plan must have enough licenses to be able to run parallel tests. If more tests are activated than you have subscribed to, they will be queued or discarded.

In this guide, you will learn how to:

  1. set up your environment
  2. Upload your application
  3. Configure and run parallel tests
  4. View test execution results

Use:If you have already passed through ourRun your first testguide, you can jump to theConfigure and run parallel testssection.

1. Set up your environment

  • You will need a BrowserStackUsernameyaccess key. If you haven't created an account yet, sign up for oneFree Trialor buy apaid plan. After registering, you can get your login credentials fromaccount settings
  • Make sure you have Python 3.6+ or Python 2.7+ installed on your system. You can download updated versions of Python
  • Make sure you have package managernuggetinstalled on your system. Installnugget, follow the steps described in theinstallation guide
  • You will need access to your Android app (.apko.aabfile) or iOS app (.ipaarchive)

Use:If you don't have a.apko.ipaand are looking to just try App Automate, you can download and try using ourandroid application exampleoexample application for iOS.

2. Upload your application

Upload your Android app (.apko.aabfile) or iOS app (.ipafile) to BrowserStack servers using our REST API. here is an examplericeRequest to upload the app to App Automate:

  • OS X y Linux
  • windows
rice-tu "YOUR_USERNAME:YOUR_ACCESS_KEY" \-XCORREO"" \-F "file=@/path/to/apk/file"
(Video) Part 14 - Appium Latest Tutorial - Run tests in Parallel in Browserstack cloud - TestNG Dataprovider
rice-tu "YOUR_USERNAME:YOUR_ACCESS_KEY"^-XCORREO""^-F "file=@/path/to/apk/file"

make sure that@The symbol is prepended to the file path in the above request. Below is a sample response for the above request:

{ "application_url" : "bs://j3c874f21852ba57957a3fdc33f47514288c4ba4"}

Keep in mind theapp_urlreturn value in API response (bs:// the example above). We'll use this value to set the app under test as we set up the test later.


  1. The app will take anywhere from a few seconds to about a minute to load depending on the size of your app. don't interrupt thericecommand until you get the response.
  2. If you upload an iOS app, we'll re-sign the app with our own provisioning profile so we can install your app on our devices during the test run.

3. Set up and run parallel tests

configure your project

Clone theBehave sample integration codefrom our GitHub repository.

git clone

Then, run the following command from the project's base directory to install the required dependencies:

# Test an Android applicationnuggetinstall -randroid/requisitos.txt# Test an iOS appnuggetinstall -rios/requirements.txt
(Video) Lesson 32 - Multiple Devices for Parallel Testing on same machine

This will install the necessary dependencies, includingA Python client library for Appium:

behave==1.2.6selenium==3.141.0Appium-Python-Client==0.52;python_version < '3.0'Appium-Python-Client==1.0.2;python_version >= '3.0'browserstack-local==1.2.2paver = =1.3.4psutil==5.7.2

Configuring Appium Desired Capabilities

The desired capabilities are a series of key-value pairs that allow you to set up your Appium tests on BrowserStack. The following capabilities are required:

  • browserstack.usuariocapacity: used to specify your BrowserstackUsernamecredential
  • browserstack.clavecapacity: used to specify your Browserstackaccess keycredential
  • applicationcapacity: used to specify the loaded application to be installed on the device during the test execution. Use theapp_urlobtained inUpload your applicationsection to set its value.
  • devicecapacity – Used to specify the BrowserStack device on which you want to run the test.

In itBehave sample integration code, the desired capabilities of Appium are defined in theconfig.jsonfile located in theexamples/run-parallel-testsdirectory. Note the use ofenvironmentskey to specify a list of devices for parallel test execution.

  • Android
  • iOS
{ "capabilities": { "browserstack.usuario" : "YOUR USERNAME", "browserstack.clave" : "YOUR_ACCESS_KEY", "project": "Android First Behave Project", "build": "Behave Android in parallel", "name": "parallel_test", "navegadorstack.debug": TRUE, "application": "bs://" }, "environments": [{ "device": "Google Pixel 3", "operating system version": "9.0" }, { "device": "Samsung Galaxy S10e", "operating system version": "9.0" }]}
{ "capabilities": { "browserstack.usuario" : "YOUR USERNAME", "browserstack.clave" : "YOUR_ACCESS_KEY", "project": "Proyecto First Behave iOS", "build": "Behave iOS in Parallel", "name": "parallel_test", "navegadorstack.debug": TRUE, "application": "bs://" }, "environments": [{ "device": "iPhone 11 Pro", "operating system version": "13" }, { "device": "iPhone 11 Pro Max", "operating system version": "13" }]}


  • You can also provide access credentials to BrowserStack by configuringNAVEGADORSTACK_USERNAME&NAVEGADORSTACK_ACCESS_KEYEnvironment Variables
  • You can explore other Appium capabilities using ourcapacity builder
(Video) Part 24- Parallel Test Execution in Robot Framework | Selenium with Python

Create a remote web controller

Once you've configured the desired capabilities, you can initialize an Appium web driver to test remotely on BrowserStack. To do this, you must use a remote BrowserStack URL along with the desired capabilities.

In itBehave sample integration code, the remote Webdriver is initialized on theenvironment.pyfile located in theexamples/run-parallel-tests/featuresdirectory as shown below:

#...# Initialize the remote Webdriver using the BrowserStack remote URL # and the desired capabilities defined above context.browser = web controller.Remote ( desired_capabilities=desired_capabilities, command_executor="" )#...

Set up your test case

This step will help you set up a test case with the Behave Framework that will run in parallel on multiple devices. In itBehave sample integration code, we have provided an example test case inexamples/run-parallel-tests/featuresdirectory for BrowserStack sample applications. If you are testing your own application, modify the test case accordingly.

  • Android
  • iOS

Define the scenario you want to test in the application inparallel_test.featurearchive:

Feature: Wikipedia search functionality scenario: I can find search results Since I open the application and search for the keyword "BrowserStack", then the search results should appear

Provide the implementation of the steps used in the scenario inpasos.pyarchive:

matter timeof appium.webdriver.common.mobileby matter MobileByof matter WebDriverWaitof matter expected_conditions as CE@given(tu'I open the application and search for the keyword "{keyword}"')definitely paso_impl(context, keyword): search_item = WebDriverWait(context.browser, 10).until( CE.presence_of_located_element((MobileBy.ACCESSIBILITY_ID, "Search Wikipedia")) ) search_input = WebDriverWait(context.browser, 30).until( CE.element_to_be_clickable((MobileBy.ID, "org.wikipedia.alpha:id/search_src_text")) ) search_input.send_keys(keyword) time.sleep(5)@so(tu'Search results should appear')definitely paso_impl(context): elements = context.browser.find_elements_by_class_name("android.widget.TextView") claim Len(elements) > 0, "unpopulated results"

Define the scenario you want to test in the application inparallel_test.featurearchive:

(Video) Appium Python Tutorial - Run Appium Test Case on iOS Simulator

Feature – Text check in sample app scenario – displayed text must match input text.

Provide the implementation of the steps used in the scenario inpasos.pyarchive:

matter timeof appium.webdriver.common.mobileby matter MobileByof matter WebDriverWaitof matter expected_conditions as CE@given('I open the app and click the Text button')definitely paso_impl(context): element = WebDriverWait(context.browser, 30).until( CE.presence_of_located_element((MobileBy.ACCESSIBILITY_ID, "Text Button")) )'Type "{text}" and press enter')definitely paso_impl(context, text): text input = WebDriverWait(context.browser, 30).until( CE.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID, "Text Input")) ) text input.send_keys(text+"\norte") time.sleep(5)@so(tu'Verify that the displayed text matches the input text')definitely paso_impl(context): text_output = WebDriverWait(context.browser, 30).until( CE.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID, "text output")) ) and text_output!=None y text_output.text=="": claim TRUE the rest: claim FALSE

run the test

You are ready to run parallel tests on BrowserStack. In itBehave sample integration code, switch toexamples/run-parallel-testsdirectory, and run the test using the command:

# Run using paverpaver run parallel_tests

4. View the results of the test run

You can access test run results and debugging information such as video recording, network, and device logs.App Automation Dashboardor using ourAPI REST.

I need help?

If you have any questions, pleaseContact us.

Was this page helpful?

We're sorry to hear that. Please share your feedback so we can do better.

Get in touch with ourSupport teamfor immediate help as we work to improve our documents.

We are continually improving our documents. We'd love to know what you liked

(Video) Lecture 26 - Test Execution on Browserstack and Saucelabs using Appium

Thank you for your valuable comments.


1. How To Run Selenium Tests on Saucelabs
(SDET- QA Automation Techie)
2. Run Parallel Tests on Sauce Labs with an Android Appium Tests
(Sauce Labs)
3. Appium Python - Running the very first test on a Web browser
(Way2Automation - Rahul Arora)
4. Appium Pro Tips - TAQELAH
5. Run Selenium tests on the cloud with BrowserStack
6. How To Run Selenium Tests on BrowserStack
(SDET- QA Automation Techie)


Top Articles
Latest Posts
Article information

Author: Prof. Nancy Dach

Last Updated: 01/11/2023

Views: 5437

Rating: 4.7 / 5 (57 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Prof. Nancy Dach

Birthday: 1993-08-23

Address: 569 Waelchi Ports, South Blainebury, LA 11589

Phone: +9958996486049

Job: Sales Manager

Hobby: Web surfing, Scuba diving, Mountaineering, Writing, Sailing, Dance, Blacksmithing

Introduction: My name is Prof. Nancy Dach, I am a lively, joyous, courageous, lovely, tender, charming, open person who loves writing and wants to share my knowledge and understanding with you.