PyTest Integration with BrowserStack.
-
Python 3.6+ or Python 2.7+
To install the dependencies, run the following command in project's base directory:
-
For Python 3
pip3 install -r requirements.txt
-
For Python 2
pip install -r requirements.txt
Getting Started with Pytest-Appium tests in Python on BrowserStack couldn't be easier!
1. Upload your Android or iOS App
Upload your Android app (.apk or .aab file) or iOS app (.ipa file) 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.
Note: If you do not have an .apk or .ipa file and are looking to simply try App Automate, you can download and test using our sample Android app or sample iOS app.
2. Configure and run your first single test
Open single.json file in android/run-single-test folder for Android and ios/run-single-test folder for iOS:
-
Replace
BROWSERSTACK_USERNAME&BROWSERSTACK_ACCESS_KEYwith your BrowserStack access credentials. Get your BrowserStack access credentials from here -
Replace
bs://<app-id>with the URL obtained from app upload step -
Set the deviceName and platformVersion. You can refer our Capability Generator
-
Run the below command to execute a single Android test on BrowserStack AppAutomate:
cd android paver run single -
Run the below command to execute a single iOS test on BrowserStack AppAutomate:
cd ios paver run single
3. Configure and run your parallel test
-
In order to run tests in parallel across different configurations, Open
parallel.jsonfile inandroid/run-parallel-testfolder for Android andios/run-parallel-testfolder for iOS -
Replace
BROWSERSTACK_USERNAME&BROWSERSTACK_ACCESS_KEYwith 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 Android test on BrowserStack AppAutomate:
cd android
paver run parallel
- Run the below command to execute a parallel iOS test on BrowserStack AppAutomate:
cd ios
paver run parallel
- You can access the test execution results, and debugging information such as video recording, network logs on App Automate dashboard
1. Upload your Android or iOS App
Upload your Android app (.apk or .aab file) or iOS app (.ipa file) that access resources hosted on your internal or test environments 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.
Note: If you do not have an .apk or .ipa file and are looking to simply try App Automate, you can download and test using our sample Android Local app or sample iOS Local app.
2. Configure and run your local test
Open local.json file in android/run-local-test folder for Android and ios/run-local-test folder for iOS:
-
Replace
BROWSERSTACK_USERNAME&BROWSERSTACK_ACCESS_KEYwith 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
-
Ensure that
localcapability is set totrue. Theconftest.pycontains the code snippet that automatically establishes Local Testing connection to BrowserStack servers using Python binding for BrowserStack Local. -
Run the below command for Android:
cd android paver run local -
Run the below command for iOS:
cd ios paver run local -
You can access the test execution results, and debugging information such as video recording, network logs on App Automate dashboard
