|
1 | 1 | # node-appium-app-browserstack |
2 | | -App Automate Node 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. |
| 3 | +This repository demonstrates how to run Appium NodeJS tests on BrowserStack App Automate. |
6 | 4 |
|
7 | | -For frameworks integration with BrowserStack, refer to their individual repositories - |
| 5 | +## Setup |
| 6 | + |
| 7 | +### Requirements |
| 8 | + |
| 9 | +1. Node.js |
| 10 | + |
| 11 | + - If not installed, install Node.js from [here](https://nodejs.org/en/download/) |
| 12 | + |
| 13 | + - Ensure you have node & npm installed by running `node -v` & `npm -v` |
| 14 | + |
| 15 | +### Install the dependencies |
| 16 | + |
| 17 | +To install the dependencies run the following command in the project's base directory : |
| 18 | + |
| 19 | +``` |
| 20 | +npm install |
| 21 | +``` |
| 22 | + |
| 23 | +## Getting Started |
| 24 | + |
| 25 | +Getting Started with Appium tests in NodeJS on BrowserStack couldn't be easier! |
| 26 | + |
| 27 | +### Run your first test : |
| 28 | + |
| 29 | +**1. Upoad your Android or iOS App** |
| 30 | + |
| 31 | +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 : |
| 32 | + |
| 33 | +``` |
| 34 | +curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \ |
| 35 | +-X POST "https://api-cloud.browserstack.com/app-automate/upload" \ |
| 36 | +-F "file=@/path/to/apk/file" |
| 37 | +``` |
| 38 | + |
| 39 | +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. |
| 40 | + |
| 41 | +**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). |
| 42 | + |
| 43 | +**2. Configure and run your first test** |
| 44 | + |
| 45 | +Open `BrowserStackSample.js` file in `Android` or in `ios` folder |
| 46 | + |
| 47 | +- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings) |
| 48 | + |
| 49 | +- Replace `bs://<app-id>` wkth the URL obtained from app upload step |
| 50 | + |
| 51 | +- Set the device and OS version |
| 52 | + |
| 53 | +- If you have uploaded your own app update the test case |
| 54 | + |
| 55 | +- Run `node BrowserStackSample.js` |
| 56 | + |
| 57 | +- 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) |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +### **Use Local testing for apps that access resources hosted in development or testing environments :** |
| 62 | + |
| 63 | +**1. Upload your Android or iOS App** |
| 64 | + |
| 65 | +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 : |
| 66 | + |
| 67 | +``` |
| 68 | +curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \ |
| 69 | +-X POST "https://api-cloud.browserstack.com/app-automate/upload" \ |
| 70 | +-F "file=@/path/to/apk/file" |
| 71 | +``` |
| 72 | + |
| 73 | +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. |
| 74 | + |
| 75 | +**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). |
| 76 | + |
| 77 | +**2. Configure and run your local tes** |
| 78 | + |
| 79 | +Open `BrowserStackSampleLocal.js` file in `Android` or in `ios` folder |
| 80 | + |
| 81 | +- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings) |
| 82 | + |
| 83 | +- Replace `bs://<app-id>` wkth the URL obtained from app upload step |
| 84 | + |
| 85 | +- Set the device and OS version |
| 86 | + |
| 87 | +- 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 Javascript binding for BrowserStack Local. |
| 88 | + |
| 89 | +- If you have uploaded your own app update the test case |
| 90 | + |
| 91 | +- Run `node BrowserStackSampleLocal.js` |
| 92 | + |
| 93 | +- 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) |
| 94 | + |
| 95 | +## Integration with other NodeJS frameworks |
| 96 | + |
| 97 | +For other NodeJS frameworks samples, refer to following repositories : |
8 | 98 |
|
9 | 99 | - [WebdriverIO](https://github.com/browserstack/webdriverio-appium-app-browserstack) |
| 100 | + |
| 101 | +Note: For other test frameworks supported by App-Automate refer our [Developer documentation](https://www.browserstack.com/docs/) |
| 102 | + |
| 103 | +## Getting Help |
| 104 | + |
| 105 | +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