|
1 | 1 | # python-appium-app-browserstack |
2 | | -App Automate Python Samples |
3 | | ---------------------- |
4 | 2 |
|
5 | | -This repository contains code for Automated Native App tests. Please feel free to clone the repo and use the example code. |
6 | | -Refer [Getting Started with App Automate](https://www.browserstack.com/app-automate/appium-python) for more details. |
| 3 | +This repository demonstrates how to run Appium Python tests on BrowserStack App Automate. |
| 4 | + |
| 5 | +## Setup |
| 6 | + |
| 7 | +### Requirements |
| 8 | + |
| 9 | +1. Python 3.6+ or Python 2.7+ |
| 10 | + |
| 11 | + - For Windows, download latest python version from [here](https://www.python.org/downloads/windows/) and run the installer executable |
| 12 | + - For Mac and Linux, run `python --version` to see what python version is pre-installed. If you want a different version download from [here](https://www.python.org/downloads/) |
| 13 | + |
| 14 | +2. Package Manager pip |
| 15 | + |
| 16 | + Note : `pip` comes installed with Python 2.7.9+ and python 3.4+ |
| 17 | + |
| 18 | + - If `pip` is not installed, follow these instructions: |
| 19 | + - Securely download get-pip.py by following this link: [get-pip.py](https://bootstrap.pypa.io/get-pip.py) or use following cURL command to download it: |
| 20 | + |
| 21 | + ```sh |
| 22 | + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py |
| 23 | + ``` |
| 24 | + |
| 25 | + - After dowloading, run the file : |
| 26 | + |
| 27 | + - For Python 3 |
| 28 | + |
| 29 | + ```sh |
| 30 | + python3 get-pip.py |
| 31 | + ``` |
| 32 | + |
| 33 | + - For Python 2 |
| 34 | + |
| 35 | + ```sh |
| 36 | + python2 get-pip.py |
| 37 | + ``` |
| 38 | + |
| 39 | +### Install the dependencies |
| 40 | + |
| 41 | +To install the dependencies, run the following command in project's base directory: |
| 42 | +
|
| 43 | +- For Python 3 |
| 44 | +
|
| 45 | + ```sh |
| 46 | + pip3 install -r requirements.txt |
| 47 | + ``` |
| 48 | +
|
| 49 | +- For Python 2 |
| 50 | +
|
| 51 | + ```sh |
| 52 | + pip2 install -r requirements.txt |
| 53 | + ``` |
| 54 | +
|
| 55 | +## Getting Started |
| 56 | +
|
| 57 | +Getting Started with Appium tests in Python on BrowserStack couldn't be easier! |
| 58 | + |
| 59 | +### Run your first test : |
| 60 | + |
| 61 | +**1. Upload your Android or iOS App** |
| 62 | + |
| 63 | +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 : |
| 64 | + |
| 65 | +``` |
| 66 | +curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \ |
| 67 | +-X POST "https://api-cloud.browserstack.com/app-automate/upload" \ |
| 68 | +-F "file=@/path/to/apk/file" |
| 69 | +``` |
| 70 | +
|
| 71 | +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. |
| 72 | +
|
| 73 | +**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](https://www.browserstack.com/app-automate/sample-apps/android/WikipediaSample.apk) or [sample iOS app](https://www.browserstack.com/app-automate/sample-apps/ios/BStackSampleApp.ipa). |
| 74 | +
|
| 75 | +
|
| 76 | +**2. Configure and run your first test** |
| 77 | +
|
| 78 | +Open `browserstack_sample.py` file in `Android` or `iOS` folder : |
| 79 | +
|
| 80 | +- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings) |
| 81 | +
|
| 82 | +- Replace `bs://<app-id>` wkth the URL obtained from app upload step |
| 83 | +
|
| 84 | +- Set the device and OS version |
| 85 | +
|
| 86 | +- If you have uploaded your own app update the test case |
| 87 | +
|
| 88 | +- Run `python browserstack_sample.py` |
| 89 | +
|
| 90 | +- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard) |
| 91 | +
|
| 92 | +--- |
| 93 | +
|
| 94 | +### **Use Local testing for apps that access resources hosted in development or testing environments :** |
| 95 | +
|
| 96 | +**1. Upload your Android or iOS App** |
| 97 | +
|
| 98 | +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 : |
| 99 | +
|
| 100 | +``` |
| 101 | +curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \ |
| 102 | +-X POST "https://api-cloud.browserstack.com/app-automate/upload" \ |
| 103 | +-F "file=@/path/to/apk/file" |
| 104 | +``` |
| 105 | +
|
| 106 | +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. |
| 107 | +
|
| 108 | +**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](https://www.browserstack.com/app-automate/sample-apps/android/LocalSample.apk) or [sample iOS Local app](https://www.browserstack.com/app-automate/sample-apps/ios/LocalSample.ipa). |
| 109 | +
|
| 110 | +
|
| 111 | +**2. Configure and run your local test** |
| 112 | +
|
| 113 | +Open `browserstack_sample_local` file in `Android` or `iOS` folder : |
| 114 | +
|
| 115 | +- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings) |
| 116 | +
|
| 117 | +- Replace `bs://<app-id>` wkth the URL obtained from app upload step |
| 118 | +
|
| 119 | +- Set the device and OS version |
| 120 | +
|
| 121 | +- Ensure that `browserstack.local` capability is set to `true`. Within the test script, there is code snippet that automatically establishes Local Testing connection to BrowserStack servers using Python binding for BrowserStack Local. |
| 122 | +
|
| 123 | +- If you have uploaded your own app update the test case |
| 124 | +
|
| 125 | +- Run `python browserstack_sample_local.py` |
| 126 | +
|
| 127 | +- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard) |
| 128 | +
|
| 129 | +## Integration with other python frameworks |
| 130 | +
|
| 131 | +For other Python frameworks samples, refer to following repositories : |
7 | 132 |
|
8 | | -For frameworks integration with BrowserStack, refer to their individual repositories - |
9 | | -- [Lettuce](https://github.com/browserstack/lettuce-appium-app-browserstack) |
10 | 133 | - [Behave](https://github.com/browserstack/behave-appium-app-browserstack) |
| 134 | +- [Lettuce](https://github.com/browserstack/lettuce-appium-app-browserstack) |
| 135 | +
|
| 136 | +Note: For other test frameworks supported by App-Automate refer our [Developer documentation](https://www.browserstack.com/docs/) |
| 137 | +
|
| 138 | +## Getting Help |
11 | 139 |
|
12 | | -For python 2 support refer the branch |
13 | | -- [python-2-master](https://github.com/browserstack/python-appium-app-browserstack/tree/python-2-master) |
| 140 | +If you are running into any issues or have any queries, please check [Browserstack Support page](https://www.browserstack.com/support/app-automate) or [get in touch with us](https://www.browserstack.com/contact?ref=help). |
0 commit comments