PyTest Integration with BrowserStack for Appium.
This repository demonstrates an Appium test framework written in Pytest BDD (Behavior Driven Development) with parallel testing capabilities. It leverages the power of Pytest and the pytest-bdd plugin to write and execute BDD-style tests for mobile applications. The Appium script is designed for automating tests on the Wikipedia Sample Android app.
Ensure you have Python 3.6+
- For Windows, download latest python version from here and run the installer executable
- For Mac and Linux, run
python --version
to see what python version is pre-installed. If you want a different version download from here
-
Clone the repository
-
Install dependencies :
Run the following command in project's base directory:
pip3 install -r requirements.txt
- Upload the Wikipedia Sample Android App
Upload the Wikipedia Sample Android app to BrowserStack servers using our REST API. Here is an example cURL request :
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@/path/to/apk/file"
Ensure that @ symbol is prepended to the file path in the above request. Please note the app_url
value returned in the API response. We will use this to set the application under test while configuring the test later on.
In order to run tests in parallel across different configurations, Open browserstack.yml
file
-
Replace
BROWSERSTACK_USERNAME
&BROWSERSTACK_ACCESS_KEY
with your BrowserStack access credentials. Get your BrowserStack access credentials from here -
Replace
bs://<app-id>
wkth the URL obtained from app upload step -
Set the deviceName and platformVersion. You can refer our Capability Generator
-
Run the below command to execute parallel test on BrowserStack AppAutomate:
browserstack-sdk pytest -s tests/test_wikipedia.py
-
You can access the test execution results, and debugging information such as video recording, network logs on App Automate dashboard
-
You can export the environment variables for your BrowserStack account's Username and Access Key, along with the App ID.
- For Mac and Linux:
export BROWSERSTACK_USERNAME=<browserstack-username> && export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key> && export BROWSERSTACK_APP_ID=<app_url or custom_id>
- For Windows:
set BROWSERSTACK_USERNAME=<browserstack-username> set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key> set BROWSERSTACK_APP_ID=<app_url or custom_id>