|
1 | 1 | # parallel_appium |
2 | 2 |
|
3 | | -Distributed mobile testing in Appium |
| 3 | +Single/Distributed Parallel Cross-Platform mobile testing in Appium and RSpec for Android and iOS. |
| 4 | + |
| 5 | +This project acts as a wrapper around a number of the configurations that have to be in place for |
| 6 | +running appium tests with RSpec. |
| 7 | + |
| 8 | +The Gem: |
| 9 | + |
| 10 | +* Handles single platform testing |
| 11 | +* Does cross-platform testing in Parallel |
| 12 | +* Distributes tests across multiple simulator instances for a platform |
| 13 | + |
| 14 | +Using the gem will speed up the time your entire test suite takes to execute and reducing your |
| 15 | +project size by packaging a lot of code that is not context-specific. |
| 16 | + |
| 17 | +This project depends on [Appium](http://appium.io/), please ensure you've installed and configured Appium |
| 18 | +correctly before trying to work with this gem. [Appium Doctor](https://github.com/appium/appium-doctor) is a good way to |
| 19 | +ensure you're good to go here |
| 20 | + |
| 21 | +## Sample Project |
| 22 | + |
| 23 | +To better demonstrate how to use the gem, a project automating Wordpress's mobile apps |
| 24 | +is presented [here](https://github.com/JavonDavis/Wordpress-Open-Source-Automation-Ruby). |
| 25 | + |
| 26 | +This project shows hands on how to integrate the gem and what it can do. |
4 | 27 |
|
5 | 28 | ## Installation |
6 | 29 |
|
7 | 30 | Add this line to your application's Gemfile: |
8 | 31 |
|
9 | | -```ruby |
| 32 | +``` |
10 | 33 | gem 'parallel_appium' |
11 | 34 | ``` |
12 | 35 |
|
13 | 36 | And then execute: |
14 | 37 |
|
15 | | - $ bundle |
| 38 | + $ bundle install |
16 | 39 |
|
17 | 40 | Or install it yourself as: |
18 | 41 |
|
19 | 42 | $ gem install parallel_appium |
| 43 | + |
| 44 | +## Getting setup |
| 45 | + |
| 46 | +## Android |
| 47 | + |
| 48 | +The gem uses the emulator command line tool that comes with your Android installation to manage a number of things. This |
| 49 | +however requires a bit of configuration to work properly as by default it's not added to the system path and it's usually |
| 50 | +not pointing to the correct one. Adding something like this(**in the specified order**) in your bash_profile will resolve |
| 51 | +this |
| 52 | + |
| 53 | +``` |
| 54 | +export ANDROID_HOME=/<path>/to/Android/sdk |
| 55 | +export ANDROID_AVD_HOME=~/.android/avd |
| 56 | +export PATH=$ANDROID_HOME/platform-tools:$PATH |
| 57 | +export PATH=$ANDROID_HOME/tools:$PATH |
| 58 | +export PATH=$ANDROID_HOME/tools/bin:$PATH |
| 59 | +export PATH=$ANDROID_HOME/emulator:$PATH |
| 60 | +``` |
| 61 | + |
| 62 | +## iOS |
| 63 | + |
| 64 | +The main requirement here is to be running on a MAC machine, otherwise, there's nothing extra to do here |
| 65 | +all the requirements for Appium and iOS hold true. |
| 66 | + |
| 67 | +### Additional check |
| 68 | + |
| 69 | +I also recommend an additional check to see if you're good to go for this project, simply execute |
| 70 | + |
| 71 | +```bundle install --path vendor``` |
| 72 | + |
| 73 | +and then |
| 74 | + |
| 75 | +```bundle exec rake parallel_appium:validate_android``` for Android |
| 76 | + |
| 77 | +or |
| 78 | + |
| 79 | +```bundle exec rake parallel_appium:validate_ios``` for iOS |
| 80 | + |
| 81 | + |
| 82 | +The messages will indicate if there's any component necessary for the platform that's still not set up as yet. |
| 83 | + |
20 | 84 |
|
21 | 85 | ## Usage |
22 | 86 |
|
23 | | -TODO: Write usage instructions here |
| 87 | +To get started with this gem in a project there's 3 lines of code you'll need to know to include within your project. |
| 88 | +These lines handle the following. |
| 89 | + |
| 90 | +### Starting the servers |
| 91 | + |
| 92 | +The library at the moment doesn't offer the ability to connect to existing appium processes and instead |
| 93 | +starts appium servers and the selenium grid server as needed. The following line of code is what you'll need to include |
| 94 | +for the library to handle this, |
| 95 | + |
| 96 | +```ParallelAppium::ParallelAppium.new.start platform: platform, file_path: file_path``` |
| 97 | + |
| 98 | +where platform is either android, ios or all and file_path is the absolute path to the folder or spec file |
| 99 | +to be executed. |
| 100 | + |
| 101 | +### Initializing the appium instance(s) |
| 102 | + |
| 103 | +As expected each appium instance will need to be loaded with capabilities defining all kinds of important things |
| 104 | +about how the tests executing on that instance will work, hence this will need to be done before the tests begin |
| 105 | +it's best to put this in some form of 'before all' block that will execute it prior to all the tests executing. |
| 106 | + |
| 107 | +The following line of code is an example of what you'll need to use |
| 108 | + |
| 109 | +```ParallelAppium::ParallelAppium.new.initialize_appium platform: ENV['platform']``` |
| 110 | + |
| 111 | +The initialize_appium function can take two parameters |
| 112 | + |
| 113 | +1. platform - If provided it will look for a appium-{platform}.txt file in the root of the project and load capabilities |
| 114 | +from that location. |
| 115 | +2. caps - The capabilities as a map to be loaded. |
| 116 | + |
| 117 | +### Setting UDID for the test |
| 118 | + |
| 119 | +When distributing tests across multiple devices the library spreads the specs across multiple threads and depends on the |
| 120 | +UDID environment variable to know which device it's working with for the specific test file, as such this will need to |
| 121 | +be setup in each test file, simply include the following line of code at the top of the test file after any dependencies |
| 122 | +and the library will set this up as needed, |
| 123 | + |
| 124 | +```ParallelAppium::Server.new.set_udid_environment_variable``` |
| 125 | + |
| 126 | +This is all you need to get started with this library. There's a number of environment variables set by the library |
| 127 | +for the purpose of writing easier cross platform tests. These are described in more detail below. |
| 128 | + |
| 129 | + |
| 130 | +-------- |
| 131 | + |
| 132 | +Next you'll need to ensure the project the respective appium text files for the platform, |
| 133 | +the gem will be looking for these files in the Project root. This file is used to load the capabilities of the driver |
| 134 | +at launch. |
| 135 | + |
| 136 | +Here's examples of what both could look like |
| 137 | + |
| 138 | +### appium-ios.txt |
| 139 | + |
| 140 | +``` |
| 141 | +[caps] |
| 142 | +platformName = "ios" |
| 143 | +deviceName = "iPhone Simulator" |
| 144 | +platformVersion = "11.4" |
| 145 | +app = "./apps/WordPress.app.zip" |
| 146 | +automationName = "XCUITest" |
| 147 | +bundleId = "org.wordpress" |
| 148 | +
|
| 149 | +[appium_lib] |
| 150 | +wait = 2 |
| 151 | +``` |
| 152 | + |
| 153 | +### appium-android.txt |
| 154 | + |
| 155 | +``` |
| 156 | +[caps] |
| 157 | +platformName = "android" |
| 158 | +deviceName = "Android Emulator" |
| 159 | +platformVersion = "8.1.0" |
| 160 | +app = "./apps/WordPress.apk" |
| 161 | +appActivity = "org.wordpress.android.ui.WPLaunchActivity" |
| 162 | +appPackage = "org.wordpress.android" |
| 163 | +
|
| 164 | +[appium_lib] |
| 165 | +wait = 2 |
| 166 | +``` |
| 167 | + |
| 168 | +The vales are expected to change to tailor to the host machine. |
| 169 | + |
| 170 | +### Environment variables |
| 171 | + |
| 172 | + |
| 173 | +### Tags |
| 174 | + |
| 175 | + |
24 | 176 |
|
25 | 177 | ## Development |
26 | 178 |
|
|
0 commit comments