|
1 | 1 | # ruby-appium-app-browserstack |
2 | | -App Automate Ruby 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 Ruby 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. Ruby 2.2+ |
| 10 | + |
| 11 | + - If not installed, install Ruby from [here](https://www.ruby-lang.org/en/documentation/installation/) |
| 12 | + |
| 13 | +2. Dependency Manager `bundler` |
| 14 | + |
| 15 | + - If not installed, run command `gem install bundler` |
| 16 | + |
| 17 | +### Install the dependencies |
| 18 | + |
| 19 | +To install the dependencies, run the following command in the project's base directory : |
| 20 | + |
| 21 | +```ruby |
| 22 | +bundle install |
| 23 | +``` |
| 24 | + |
| 25 | +**Note**: If you are using Windows, RubyInstaller has a known [issue](https://github.com/oneclick/rubyinstaller2/issues/96). Run the following script as a workaround to resolve it - |
| 26 | + |
| 27 | +```ruby |
| 28 | +gem install ffi |
| 29 | +gem uninstall -aIx eventmachine |
| 30 | +gem install eventmachine --platform=ruby |
| 31 | +``` |
| 32 | + |
| 33 | +## Getting Started |
| 34 | + |
| 35 | +Getting Started with Appium tests in Ruby on BrowserStack couldn't be easier! |
| 36 | + |
| 37 | +### Run your first test : |
| 38 | + |
| 39 | +**1. Upload your Android or iOS App** |
| 40 | +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 : |
| 41 | + |
| 42 | +``` |
| 43 | +curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \ |
| 44 | +-X POST "https://api-cloud.browserstack.com/app-automate/upload" \ |
| 45 | +-F "file=@/path/to/apk/file" |
| 46 | +``` |
| 47 | + |
| 48 | +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. |
| 49 | + |
| 50 | +**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). |
| 51 | + |
| 52 | +**2. Configure and run your first test** |
| 53 | + |
| 54 | +Open `browserstack_sample.rb` file in `android` or `ios` directory : |
| 55 | + |
| 56 | +- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings) |
| 57 | + |
| 58 | +- Replace `bs://<app-id>` wkth the URL obtained from app upload step |
| 59 | + |
| 60 | +- Set the device and OS version |
| 61 | + |
| 62 | +- If you have uploaded your own app update the test case |
| 63 | + |
| 64 | +- Run `ruby browserstack_sample.rb` |
| 65 | + |
| 66 | +- 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) |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +### Use Local testing for apps that access resources hosted in development or testing environments : |
| 71 | + |
| 72 | +**1. Upload your Android or iOS App** |
| 73 | + |
| 74 | +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 : |
| 75 | + |
| 76 | +``` |
| 77 | +curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \ |
| 78 | +-X POST "https://api-cloud.browserstack.com/app-automate/upload" \ |
| 79 | +-F "file=@/path/to/apk/file" |
| 80 | +``` |
| 81 | + |
| 82 | +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. |
| 83 | + |
| 84 | +**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). |
| 85 | + |
| 86 | + |
| 87 | +**2. Configure and run your local test** |
| 88 | + |
| 89 | +Open `browserstack_sample_local.rb` file in `android` or `ios` directory : |
| 90 | + |
| 91 | +- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings) |
| 92 | + |
| 93 | +- Replace `bs://<app-id>` wkth the URL obtained from app upload step |
| 94 | + |
| 95 | +- Set the device and OS version |
| 96 | + |
| 97 | +- 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 Ruby binding for BrowserStack Local. |
| 98 | + |
| 99 | +- If you have uploaded your own app update the test case |
| 100 | + |
| 101 | +- Run `ruby browserstack_sample_local.rb` |
| 102 | + |
| 103 | +- 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) |
| 104 | + |
| 105 | +## Integration with other frameworks |
| 106 | + |
| 107 | +For other Ruby frameworks samples, refer to following repositories : |
8 | 108 |
|
9 | 109 | - [Cucumber](https://github.com/browserstack/cucumber-ruby-appium-app-browserstack) |
| 110 | + |
| 111 | +Note: For other test frameworks supported by App-Automate refer our [Developer documentation](https://www.browserstack.com/docs/) |
| 112 | + |
| 113 | +## Getting Help |
| 114 | + |
| 115 | +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